image BIG

UITableView * _TabView;

NSArray * MessageArr;

UITapGestureRecognizer * tapGest;

#define KHIGHT  200

MessageArr =[NSArray arrayWithObjects:@"abc",@"abc",@"abc", nil];

_TabView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];

_TabView.delegate = self;

_TabView.dataSource = self;

[self.view addSubview:_TabView];

_TabView.contentInset = UIEdgeInsetsMake(KHIGHT, 0, 0, 0);

UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, -KHIGHT, [UIScreen mainScreen].bounds.size.width, KHIGHT)];

imageView.image = [UIImage imageNamed:@"3.jpg"];

//图片设置为填充模式

imageView.contentMode = UIViewContentModeScaleAspectFill;

//剪切到边界

imageView.clipsToBounds = YES;

imageView.tag = 101;

UIImageView * IMG = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"3.jpg"]];

IMG.frame = CGRectMake(self.view.frame.size.width/2-30,-30, 60, 60);

IMG.layer.cornerRadius = 30;

IMG.layer.masksToBounds = YES;

//给图片添加点击事件

tapGest = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(PressImg)];

//将图片与点击事件绑定

[IMG addGestureRecognizer:tapGest];

//允许图片被用户点击

IMG.userInteractionEnabled=YES;

[_TabView addSubview:imageView];

[_TabView addSubview:IMG];


//设置tableview 的行数

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

return MessageArr.count;

}

//设置

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

static NSString * cellid = @"cellid";

UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellid];

if (!cell) {

cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellid];

cell.textLabel.text = [MessageArr objectAtIndex:indexPath.row];

}

//取消选中变灰

cell.selectionStyle = UITableViewCellSelectionStyleNone;

return cell;

}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView

{

CGPoint point = scrollView.contentOffset;

if (point.y < -KHIGHT) {

CGRect rect = [_TabView viewWithTag:101].frame;

rect.origin.y = point.y;

rect.size.height = -point.y;

[_TabView viewWithTag:101].frame = rect;

}

}

-(void)PressImg{

NSLog(@"点击了图片");

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • *7月8日上午 N:Block :跟一个函数块差不多,会对里面所有的内容的引用计数+1,想要解决就用__block...
    炙冰阅读 2,554评论 1 14
  • 1、设置UILabel行间距 NSMutableAttributedString* attrString = [[...
    十年一品温如言1008阅读 1,741评论 0 3
  • 1、禁止手机睡眠[UIApplication sharedApplication].idleTimerDisabl...
    DingGa阅读 1,148评论 1 6
  • 1、模块化 为什么要使用模块化Javascript在发展初期就是为了实现简单的页面交互逻辑,故简单的引入几个脚本即...
    七_五阅读 301评论 0 0
  • 对于拆书帮,慕名很久,10月22日终于有机会参加拆书帮组织的线上活动了。此次线上活动的题目是《如何精打细算 治...
    宁博Villa阅读 432评论 1 1