欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

iOS實現(xiàn)帶遮罩的彈出選項卡

 更新時間:2020年02月22日 08:24:35   作者:will_han  
這篇文章主要為大家詳細介紹了iOS實現(xiàn)彈出選項卡,并附帶遮罩,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

在我們日常開發(fā)的過程中難免會碰到一些選項的需求,下面是我針對我們該次需求做的一個小的Demo,閑話不多說了,上圖片,上代碼。

這樣在我們選擇上面一個Cell進行點擊的時候,我會通過一個代理把數(shù)據(jù)傳遞到下面的頁面,下面是代碼

//
// LCAlertListView.h
// MeiMeiDu
//
// Created by 韓偉佳 on 16/4/6.
// Copyright © 2016年 LangCuang. All rights reserved.
//
 
#import <UIKit/UIKit.h>
@class LCAlertListView;
 
@protocol LCAlertListViewDelegate <NSObject>
 
-(void)alertListView:(LCAlertListView*)view didSelectedRow:(NSInteger)row;
 
@end
 
@interface LCAlertListView : UIView<UITableViewDataSource, UITableViewDelegate>
 
-(instancetype)initWithFrame:(CGRect)frame datas:(NSArray*)datas;
-(instancetype)initWithFrame:(CGRect)frame datas:(NSArray*)datas count:(NSArray*)counts;
@property(nonatomic, strong) id<LCAlertListViewDelegate> delegate;
@end

下面是具體實現(xiàn)

//
// LCAlertListView.m
// MeiMeiDu
//
// Created by 韓偉佳 on 16/4/6.
// Copyright © 2016年 LangCuang. All rights reserved.
//
 
#import "LCAlertListView.h"
#import "NoFreeCell.h"
 
static CGFloat TableViewHeight ;
 
@implementation LCAlertListView{
 UITableView* mTableView;
 NSArray* tableData;
 NSArray* visiableData;
 NSArray* visiableCount;
 UIButton* backgroundBtn;
}
 
-(instancetype)initWithFrame:(CGRect)frame datas:(NSArray*)datas{
 if (self = [super initWithFrame:frame]) {
 self.backgroundColor = [UIColor clearColor];
 backgroundBtn = [[UIButton alloc] initWithFrame:frame];
 backgroundBtn.backgroundColor = RGBA(88, 88, 88, 0.8);
 [backgroundBtn addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside];
 [self addSubview:backgroundBtn];
 tableData = datas;
 TableViewHeight = (datas.count + 1) * 44 + 20;
 mTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, kScreenHeight, kScreenWidth, TableViewHeight) style:UITableViewStylePlain];
 [mTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
 mTableView.delegate = self;
 mTableView.dataSource = self;
 [self addSubview:mTableView];
 [UIView animateWithDuration:.25 animations:^{
 [mTableView setFrame:CGRectMake(0, kScreenHeight - TableViewHeight, kScreenWidth, TableViewHeight)];
 } completion:^(BOOL finished) {
 
 }];
 }
 return self;
}
-(instancetype)initWithFrame:(CGRect)frame datas:(NSArray*)datas count:(NSArray*)counts{
 if (self = [super initWithFrame:frame]) {
 self.backgroundColor = [UIColor clearColor];
 backgroundBtn = [[UIButton alloc] initWithFrame:frame];
 backgroundBtn.backgroundColor = RGBA(88, 88, 88, 0.8);
 [backgroundBtn addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside];
 [self addSubview:backgroundBtn];
 visiableData = datas;
 visiableCount = counts;
 TableViewHeight = (datas.count + 1) * 44 + 20;
 mTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, kScreenHeight, kScreenWidth, TableViewHeight) style:UITableViewStylePlain];
 [mTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
 mTableView.delegate = self;
 mTableView.dataSource = self;
 [self addSubview:mTableView];
 [UIView animateWithDuration:.25 animations:^{
 [mTableView setFrame:CGRectMake(0, kScreenHeight - TableViewHeight, kScreenWidth, TableViewHeight)];
 } completion:^(BOOL finished) {
 
 }];
 }
 return self;
}
 
 
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
 if(tableData.count > 0){
 return [tableData count];
 }else if (visiableCount.count > 0){
 return [visiableCount count];
 }
 return nil;
}
 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
 UITableViewCell* cell;
 NoFreeCell *doubleCell;
 if([tableData count] <= 3 && [tableData count] > 0){
 cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
 cell.textLabel.text = tableData[indexPath.row];
 return cell;
 
 }else {
 static NSString *identifier = @"cell0";
 doubleCell =[tableView dequeueReusableCellWithIdentifier:identifier];
 if (doubleCell == nil){
 doubleCell= [[NoFreeCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
 doubleCell.visibleRoleLabel.text = visiableData[indexPath.row];
 doubleCell.showVisibleRoleLabel.text = visiableCount[indexPath.row];
 }
 return doubleCell;
 }
 
}
 
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
 NSInteger row = indexPath.row;
 [self dismiss:row];
}
 
-(void)dismiss:(NSInteger) row{
 if (_delegate && [_delegate respondsToSelector:@selector(alertListView:didSelectedRow:)]) {
 [_delegate alertListView:self didSelectedRow:row];
 }
 
 [UIView animateWithDuration:.15 animations:^{
 [mTableView setFrame:CGRectMake(0, kScreenHeight, kScreenWidth, TableViewHeight)];
 } completion:^(BOOL finished) {
 [self removeFromSuperview];
 }];
 
}
 
-(void)dismiss{
 [UIView animateWithDuration:.15 animations:^{
 [mTableView setFrame:CGRectMake(0, kScreenHeight, kScreenWidth, TableViewHeight)];
 } completion:^(BOOL finished) {
 [self removeFromSuperview];
 }];
}
@end

上面的NoFree 文件只是一個自定義的Cell,我們可以根據(jù)自己的需求自己設計,就不上傳了,最后我們說說用法:

LCAlertListView* alertListView = [[LCAlertListView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight) datas:visibleRoleArray count:visibleRoleCountArray];
 alertListView.delegate = self;
 [[[self.view superview] superview] addSubview:alertListView];

下面是代理傳值的使用

#pragma mark - LCAlertListViewDelegate
-(void)alertListView:(LCAlertListView *)view didSelectedRow:(NSInteger)row{
 if(didSelectedIndex == 0){
 testVisibleRole = visibleRoleArray[row];
 }else{
 testData = datas[row];
 }
 
 NSIndexPath *indexPath = [NSIndexPath indexPathForRow:didSelectedIndex inSection:0];
 [_myTableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}

這樣,我們的AlertTableVIew 就做好了。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

您可能感興趣的文章:

相關文章

  • iOS開發(fā)中的ViewController轉場切換效果實現(xiàn)簡介

    iOS開發(fā)中的ViewController轉場切換效果實現(xiàn)簡介

    這篇文章主要介紹了iOS開發(fā)中的ViewController轉場切換效果實,主要針對iOS7以后新加入的API進行講解,需要的朋友可以參考下
    2015-09-09
  • IOS 數(shù)據(jù)存儲詳解及實例代碼

    IOS 數(shù)據(jù)存儲詳解及實例代碼

    這篇文章主要介紹了IOS 數(shù)據(jù)存儲詳解及實例代碼的相關資料,需要的朋友可以參考下
    2017-02-02
  • 總結iOS App開發(fā)中控制屏幕旋轉的幾種方式

    總結iOS App開發(fā)中控制屏幕旋轉的幾種方式

    這篇文章主要介紹了iOS app開發(fā)中控制屏幕旋轉的方法總結,分為自動旋轉和手動旋轉以及強制旋轉三種情況,代碼為Objective-C語言,需要的朋友可以參考下
    2016-02-02
  • 總結IOS界面間跳轉的幾種方法

    總結IOS界面間跳轉的幾種方法

    前段時間被問到界面間的跳轉有幾種方式?想不到說的竟有點含糊其辭,于是就想總結一下。有句話說的好,“前人種樹,后人乘涼”,目前作為一個乘涼者,我也希望能種一些樹木,為代碼世界營造一份清新。好了,話不多說,進入主題。
    2016-08-08
  • iOS 指紋解鎖驗證TouchID功能

    iOS 指紋解鎖驗證TouchID功能

    這篇文章主要介紹了iOS 指紋解鎖驗證TouchID功能,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
    2017-03-03
  • iOS開發(fā)中class和#import的區(qū)別介紹

    iOS開發(fā)中class和#import的區(qū)別介紹

    這篇文章主要介紹了iOS開發(fā)中class和#import的區(qū)別,非常不錯,具有參考借鑒價值,需要的朋友參考下吧
    2018-02-02
  • iOS實現(xiàn)圖片自動切換效果

    iOS實現(xiàn)圖片自動切換效果

    這篇文章主要為大家詳細介紹了iOS實現(xiàn)圖片自動切換效果,類似android畫廊效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-02-02
  • iOS實現(xiàn)高效裁剪圖片圓角算法教程

    iOS實現(xiàn)高效裁剪圖片圓角算法教程

    經(jīng)??吹礁鞣N高效裁剪圓角的文章,正好之前做過一點數(shù)字圖像處理,所以寫個裁剪圓角的算法,下面這篇文章主要給大家介紹了關于iOS實現(xiàn)高效裁剪圖片圓角算法的相關資料,文中通過示例代碼介紹的非常詳細,需要的朋友可以參考下
    2018-06-06
  • iOS11適配工作及導航欄影藏返回文字的解決方法

    iOS11適配工作及導航欄影藏返回文字的解決方法

    這篇文章主要介紹了iOS11適配工作及導航欄影藏返回文字的解決方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧。
    2017-10-10
  • 去除IOS蘋果手機自帶按鈕樣式的方法(推薦)

    去除IOS蘋果手機自帶按鈕樣式的方法(推薦)

    下面小編就為大家分享一篇去除IOS蘋果手機自帶按鈕樣式的方法(推薦),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-01-01

最新評論