- (void)didClickFliterBtn:(id)sender{
NSLog(@"點擊了==========篩選");
UIView * sourceView = (UIView *)sender;
UITableViewController *menuVC = [[UITableViewController alloc] init];
__weak typeof(self)weakSelf = self;
menuVC.tableView.delegate = weakSelf ;
menuVC.tableView.dataSource = weakSelf ;
menuVC.tableView.separatorStyle = UITableViewCellSeparatorStyleNone ;
menuVC.tableView.rowHeight = 50 ;
menuVC.tableView.backgroundColor = [UIColorFromRGB(0xf9f9f9) colorWithAlphaComponent:0.1];
// menuVC.view.backgroundColor= [UIColorFromRGB(0xf9f9f9) colorWithAlphaComponent:0.7];
[menuVC.tableView registerClass:[DWHmenuCell class] forCellReuseIdentifier:@"menu"];
// 設置大小
menuVC.preferredContentSize = CGSizeMake(120, 50 * 3);
// 設置 Sytle
menuVC.modalPresentationStyle = UIModalPresentationPopover;//UIModalPresentationPopover;
// 需要通過 sourceView 來判斷位置的
menuVC.popoverPresentationController.sourceView = sourceView;
// 指定箭頭所指區域的矩形框范圍(位置和尺寸),以sourceView的左上角為坐標原點
// 這個可以 通過 Point 或 Size 調試位置
menuVC.popoverPresentationController.sourceRect = sourceView.bounds;
menuVC.popoverPresentationController.backgroundColor = [UIColorFromRGB(0xf9f9f9) colorWithAlphaComponent:0.1];
[UIColorFromRGB(0xf9f9f9) colorWithAlphaComponent:0.7];
menuVC.popoverPresentationController.containerView.layer.shadowColor = [UIColorFromRGB(0xe9e1d2) CGColor];//陰影顏色
menuVC.popoverPresentationController.containerView.layer.shadowOffset = CGSizeMake(0, 3);//width表示陰影與x的便宜量,height表示陰影與y值的偏移量
menuVC.popoverPresentationController.containerView.layer.shadowOpacity = 0.08;//
// 箭頭方向
menuVC.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionUp;
// 設置代理
menuVC.popoverPresentationController.delegate = self;
//彈出篩選菜單
[self presentViewController:menuVC animated:YES completion:nil];
}
//popover控制器是否點擊后消失
-(BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController{
return YES;
}
//實現代理方法
-(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController*)controller{
//返回UIModalPresentationNone為不匹配
return UIModalPresentationNone;
}
//已經消失的時候調用
-(void)popoverPresentationControllerDidDismissPopover:(UIPopoverPresentationController* )popoverPresentationController{
self.topView.filterBtn.selected = NO;
}
popoverPresentationController使用簡單記錄
最后編輯于 :
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
- 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
- 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
- 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
推薦閱讀更多精彩內容
- 成長記錄-連載(三十六) ——我的第一篇五千字長文,說了什么,你一定想不到 并不是不想每天寫公眾號,而是之前思考怎...
- 簡單記錄: RenderScript主要在android中的對圖形進行處理,RenderScript采用C99語法...
- 項目剛好用到,暫時只能簡單地使用,一般情況下,TabLayout都是會和ViewPager、Fragment一起使...