iOS中tableview中headerview总保持在屏幕上方和随着屏幕滑动一起移动至消失
2015-04-22 16:00
573 查看
1 : tableview中headerview总保持在屏幕上方 : 在代理方法中创建view,并添加到headerview上
l例子:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if ([self.title isEqualToString:@"幕后"]) {
NSArray *array = @[@"全部",@"电影自习室",@"电影会客厅",@"拍摄",@"综述",@"后期",@"器材"];
UIScrollView *scroller = [[UIScrollView alloc] init];
scroller.contentSize = CGSizeMake(560, 30);
scroller.backgroundColor = [UIColor whiteColor];
scroller.showsHorizontalScrollIndicator = NO;
UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:array];
segment.tintColor = [UIColor lightGrayColor];
[[UISegmentedControl appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor blackColor]} forState:UIControlStateSelected];
[scroller addSubview:segment];
return scroller;
}
return nil;
}
2 : 想随着屏幕滑动一起移动至消失的话: 就直接调用属性方法,将创建的view指定到headerview的试图()
l例子: {在viewdidload中}
self.headerView = [[HeaderView alloc] initWithFrame:CGRectMake(0, 0, 320, 150)];
self.tableView.tableHeaderView = self.headerView;
l例子:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if ([self.title isEqualToString:@"幕后"]) {
NSArray *array = @[@"全部",@"电影自习室",@"电影会客厅",@"拍摄",@"综述",@"后期",@"器材"];
UIScrollView *scroller = [[UIScrollView alloc] init];
scroller.contentSize = CGSizeMake(560, 30);
scroller.backgroundColor = [UIColor whiteColor];
scroller.showsHorizontalScrollIndicator = NO;
UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:array];
segment.tintColor = [UIColor lightGrayColor];
[[UISegmentedControl appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor blackColor]} forState:UIControlStateSelected];
[scroller addSubview:segment];
return scroller;
}
return nil;
}
2 : 想随着屏幕滑动一起移动至消失的话: 就直接调用属性方法,将创建的view指定到headerview的试图()
l例子: {在viewdidload中}
self.headerView = [[HeaderView alloc] initWithFrame:CGRectMake(0, 0, 320, 150)];
self.tableView.tableHeaderView = self.headerView;
相关文章推荐
- iOS中tableview中headerview总保持在屏幕上方和随着屏幕滑动一起移动至消失
- 怎么让tableview的section的headerView随着cell一起滑动
- 让头部tableView的HeaderView 一起随着移动
- iOS 解决tableView中headerView头部视图不跟随tableView滑动的方法
- Cell特效之图片随着TableView的滑动上下移动
- iOS tableview 区头随着一起滚动
- IOS开发笔记——实现tableView的headerView跟随cell滑动
- iOS开发-去掉UITableView HeaderView或FooterView随tableView 移动的黏性(sticky
- iOS开发之设置tableview的区头随着tableview滑动而滑动,使它不会粘在头部
- ios tableview 那些事(二十三) 解决headerView不随cell一起滚动的问题
- tableview中需要header随着cell一起滚动
- IOS开发键盘上方的view随着键盘的弹出、收起、键盘输入法改变而移动
- 让tableView的headerView和footerView跟着一起滑动
- 让TableView的header区头跟随tableView一起滑动
- ios开发之--ios11适配:TableView的heightForHeaderInSection设置高度无效/UISearchBar消失
- ios 小问题,滑动tableview,导航出去,再回来会保持原样,但我想自动保持顶部
- ios上tableview的区域随着手指滑动而动态改变
- iOS—怎样让UITableView的表头随着tableView一起滚动?这样解决
- 如何让UITableview的sectionHeader随着tableview一起滑动
- iOS tableview 区头随着cell滑动