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