iOS 使用View 为屏幕增加一个全屏的蒙层

来源:互联网 发布:索尼 2017 tgs 知乎 编辑:程序博客网 时间:2024/06/13 22:23

iOS 使用View 为屏幕增加一个全屏的蒙层 

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0,0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)]; view.backgroundColor = [UIColor blackColor]; view.alpha = 0.5; [[UIApplication sharedApplication].keyWindow addSubview:view];



主题 : 请问 如何在一个view上 显示两个tableview?


这个问题很简单,我现在用到了,声明两个tableview,给每个tableview设定tag,假定为1,2,然后在deleget 和Datesoure里边进行初始化得时候对tag进行判断,然后就可以进行相应得操作了,希望可以帮到楼主。 

实例: 
tableveiwA tag=0; 
tableveiwB tag =1; 
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ 
if (tableView.tag == 0) { 

return 1; 

else { 

return 1; 



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 
if (tableView.tag == 0) { 

return 30; 

else { 

return 10; 



- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ 
if (tableView.tag == 0) { 

return 150; 

else { 

return 50; 



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

if(tableView.tag == 0){ 
static NSString *Randoms = @"Random"; 
//add cell 
return cell; 

else { 
//add cell 

return cell; 



阅读全文
0 0
原创粉丝点击