這篇文章主要介紹IOS中MenuViewController如何實現彈出菜單效果,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
創(chuàng)新互聯堅持“要么做到,要么別承諾”的工作理念,服務領域包括:成都網站制作、成都網站設計、企業(yè)官網、英文網站、手機端網站、網站推廣等服務,滿足客戶于互聯網時代的洱源網站設計、移動媒體設計的需求,幫助企業(yè)找到有效的互聯網解決方案。努力成為您成熟可靠的網絡建設合作伙伴!效果圖:
實現方式:將self.view當前頁面縮小,在當前頁的上面添加一個菜單的view,即在self.view.superview添加。
//顯示 - (void) show:(UIView*)parent { parentView = parent; //先隱藏backView,table backView.alpha = 0; _table.alpha = 0; //移動table [_table setTransform:CGAffineTransformMakeTranslation(0, _table.frame.size.height)]; //父窗口添加本view,---這個會調用viewDidLoad [parentView.superview addSubview:self.view]; //添加動畫,添加到父窗口中,使之從下移動上 [UIView animateWithDuration:0.3 animations:^{ //父窗口縮小 CGAffineTransform t = CGAffineTransformMakeScale(0.9, 0.9); [parentView setTransform:t]; //顯示backview,table backView.alpha = 1; _table.alpha = 1; //移動table,CGAffineTransformIdentity還原原始坐標 [_table setTransform:CGAffineTransformIdentity]; } completion:^(BOOL finished) { }]; } //隱藏 - (void) hide { //添加動畫,添加到父窗口中,使之從下移動上 [UIView animateWithDuration:0.3 animations:^{ //父窗口還原 CGAffineTransform t = CGAffineTransformIdentity; [parentView setTransform:t]; //顯示backview,table backView.alpha = 0; _table.alpha = 0; //移動table [_table setTransform:CGAffineTransformMakeTranslation(0, _table.frame.size.height)]; } completion:^(BOOL finished) { [self.view removeFromSuperview]; }]; } - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor clearColor]; //背影黑罩 backView = [[UIView alloc]initWithFrame:self.view.bounds]; backView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.3]; [self.view addSubview:backView]; //算出table的CGRect CGRect rect = self.view.bounds; int height = _titleArray.count * 44; rect.origin.y = rect.size.height - height; rect.size.height = height; _table = [[UITableView alloc]initWithFrame:rect]; _table.delegate = self; _table.dataSource = self; [self.view addSubview:_table]; }
這個菜單你可以任意自定義,我這里是一個tableView,你可以寫一些有圖和文字的添加上去。只需要把源代碼稍改,就ok!
以上是“IOS中MenuViewController如何實現彈出菜單效果”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注創(chuàng)新互聯網站建設公司行業(yè)資訊頻道!
另外有需要云服務器可以了解下創(chuàng)新互聯建站www.rwnh.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
當前文章:IOS中MenuViewController如何實現彈出菜單效果-創(chuàng)新互聯
當前URL:http://www.rwnh.cn/article44/csjche.html
成都網站建設公司_創(chuàng)新互聯,為您提供網站建設、網站排名、做網站、網站設計、網頁設計公司、外貿網站建設
聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯