iOS使用自帶的UIViewController實現(xiàn)qq加號下拉菜單的功能(實例代碼)
創(chuàng)建PopViewControlller
在tableview中創(chuàng)建一個tableview用于顯示菜單
//重置控制器的大小 -(CGSize)preferredContentSize{ if (self.popoverPresentationController != nil) { CGSize tempSize ; tempSize.height = self.view.frame.size.height; tempSize.width = 150; CGSize size = [_tableVIew sizeThatFits:tempSize]; return size; }else{ return [super preferredContentSize]; } }
在viewcontroller中需要使用到得地方添加類似的代碼
environmentView.addMenuCallBack = ^(UIButton *sender){ // 設(shè)置大小 weakPopView.preferredContentSize = CGSizeMake(120, 150); // 設(shè)置 Sytle weakPopView.modalPresentationStyle = UIModalPresentationPopover; // 需要通過 sourceView 來判斷位置的 weakPopView.popoverPresentationController.sourceView = sender; //可以指示小箭頭顏色 weakPopView.popoverPresentationController.backgroundColor = [UIColor whiteColor]; // 設(shè)置指示箭頭的位置 weakPopView.popoverPresentationController.sourceRect = CGRectMake(0, 0, sender.frame.size.width*3/4, sender.frame.size.height); // 箭頭方向 weakPopView.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionUp; // 設(shè)置代理 weakPopView.popoverPresentationController.delegate = weakSelf; [weakSelf presentViewController:weakPopView animated:YES completion:nil]; };
以上所述是小編給大家介紹的iOS使用自帶的UIViewController實現(xiàn)qq加號下拉菜單的功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
詳解iOS使用Keychain中的kSecClassGenericPassword存儲數(shù)據(jù)
iOS設(shè)備中的Keychain是一個安全的存儲容器,本篇文章主要介紹了iOS使用Keychain中的kSecClassGenericPassword存儲數(shù)據(jù),有興趣的可以了解一下。2016-11-11實例講解iOS應(yīng)用的設(shè)計模式開發(fā)中的Visitor訪問者模式
這篇文章主要介紹了iOS應(yīng)用的設(shè)計模式開發(fā)中的Visitor訪問者模式的實例,示例代碼為傳統(tǒng)的Objective-C,需要的朋友可以參考下2016-03-03iOS中的音頻服務(wù)和音頻AVAudioPlayer音頻播放器使用指南
這里我們要介紹的是AVAudio ToolBox框架中的AudioServicesPlaySystemSound函數(shù)創(chuàng)建的服務(wù),特別適合用來制作鈴聲,下面就簡單整理一下iOS中的音頻服務(wù)和音頻AVAudioPlayer音頻播放器使用指南:2016-06-06iOS編程學(xué)習(xí)中關(guān)于throttle的那些事
這篇文章主要給大家介紹了關(guān)于iOS編程學(xué)習(xí)中throttle的那些事,文中通過示例代碼介紹的非常詳細,對各位iOS的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。2017-12-12