最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

在我們?nèi)粘i_發(fā)的過程中難免會(huì)碰到一些選項(xiàng)的需求,下面是我針對(duì)我們?cè)摯涡枨笞龅囊粋€(gè)小的Demo,閑話不多說了,上圖片,上代碼。

這樣在我們選擇上面一個(gè)Cell進(jìn)行點(diǎn)擊的時(shí)候,我會(huì)通過一個(gè)代理把數(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

下面是具體實(shí)現(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 文件只是一個(gè)自定義的Cell,我們可以根據(jù)自己的需求自己設(shè)計(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 就做好了。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • iOS開發(fā)中蘋果輸入手機(jī)號(hào)變用戶的名字

    iOS開發(fā)中蘋果輸入手機(jī)號(hào)變用戶的名字

    今天我們的用戶輸入手機(jī)號(hào)之后變成了用戶的名字,沒辦法獲取驗(yàn)證碼,因?yàn)槭謾C(jī)格式不對(duì)。下面通過本文給大家分享開發(fā)中蘋果輸入手機(jī)號(hào)變用戶的名字,需要的朋友可以參考下
    2017-05-05
  • fastlane自動(dòng)化打包iOS APP過程示例

    fastlane自動(dòng)化打包iOS APP過程示例

    這篇文章主要為大家介紹了fastlane自動(dòng)化打包iOS APP的過程示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-07-07
  • iOS布局渲染之UIView方法的調(diào)用時(shí)機(jī)詳解

    iOS布局渲染之UIView方法的調(diào)用時(shí)機(jī)詳解

    在你剛開始開發(fā) iOS 應(yīng)用時(shí),最難避免或者是調(diào)試的就是和布局相關(guān)的問題,下面這篇文章主要給大家介紹了關(guān)于iOS布局渲染之UIView方法調(diào)用時(shí)機(jī)的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2018-07-07
  • iOS中表單列表樣式鍵盤遮擋的解決方案

    iOS中表單列表樣式鍵盤遮擋的解決方案

    這篇文章主要給大家介紹了關(guān)于iOS中表單列表樣式鍵盤遮擋的解決方案,文中通過示例代碼將解決的方法一步步介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起看看吧
    2019-01-01
  • MAC中顯示隱藏文件和不顯示隱藏文件的方法(超簡(jiǎn)單)

    MAC中顯示隱藏文件和不顯示隱藏文件的方法(超簡(jiǎn)單)

    下面小編就為大家分享一篇MAC中顯示隱藏文件和不顯示隱藏文件的方法(超簡(jiǎn)單),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-01-01
  • iOS QQ第三方登錄實(shí)現(xiàn)

    iOS QQ第三方登錄實(shí)現(xiàn)

    這篇文章主要介紹了iOS QQ第三方登錄實(shí)現(xiàn)的全過程,一步一步告訴大家iOS QQ實(shí)現(xiàn)第三方登錄的方法,感興趣的小伙伴們可以參考一下
    2016-12-12
  • iOS10推送教程詳解

    iOS10推送教程詳解

    這篇文章主要為大家詳細(xì)介紹了iOS10推送開發(fā)教程,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-09-09
  • 剖析iOS開發(fā)中Cocos2d-x的內(nèi)存管理相關(guān)操作

    剖析iOS開發(fā)中Cocos2d-x的內(nèi)存管理相關(guān)操作

    這篇文章主要介紹了剖析iOS開發(fā)中Cocos2d-x的內(nèi)存管理相關(guān)操作,Cocos2d-x是開發(fā)游戲的利器,需要的朋友可以參考下
    2015-10-10
  • iOS 圖片壓縮方法的示例代碼

    iOS 圖片壓縮方法的示例代碼

    本篇文章主要介紹了iOS 圖片壓縮方法的示例代碼,主要有兩種壓縮圖片的方法,有興趣的可以了解一下,有興趣的可以了解一下。
    2017-01-01
  • 淺談IOS屏幕刷新ADisplayLink

    淺談IOS屏幕刷新ADisplayLink

    CADisplayLink是一個(gè)能讓我們以和屏幕刷新率相同的頻率將內(nèi)容畫到屏幕上的定時(shí)器。本文將介紹它的使用,感興趣的同學(xué),可以參考下。
    2021-06-06

最新評(píng)論

渭南市| 颍上县| 桂林市| 舟曲县| 富裕县| 河西区| 淳化县| 定结县| 金昌市| 招远市| 莆田市| 嘉祥县| 博白县| 潍坊市| 通化县| 晋州市| 砚山县| 岳阳市| 德安县| 七台河市| 苏尼特右旗| 永善县| 嘉鱼县| 东至县| 张家界市| 吉安市| 平利县| 邛崃市| 启东市| 呈贡县| 鸡西市| 贞丰县| 西乌珠穆沁旗| 集贤县| 宁乡县| 本溪| 峨眉山市| 密山市| 十堰市| 廊坊市| 双鸭山市|