Mag*_*nus 10 iphone xcode cocoa cocoa-touch objective-c
我有一个UITableView,其中包含x个单元格.但是,我希望每个单元格之间的距离为20 px.我的tableview只包含一个部分.
我在谷歌搜索并搜索论坛,但我找不到任何适用于我的目的.
是否可以设置单元格的内容偏移量或单元格内的imageview?
有人可以帮帮我吗?
这个问题的一个替代解决方案就是实现方法tableview:heightForFooterInSection之类的
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 5;
}
Run Code Online (Sandbox Code Playgroud)
然后实现tableView:ViewForFooterInSection如下//实际返回一个透明的页脚.
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
UIView *view = [[UIView alloc]init];
[view setAlpha:0.0F];
return view;
}
Run Code Online (Sandbox Code Playgroud)
基于上面评论中的后续操作,听起来您应该使用UITableView backgroundView属性来设置自定义背景图像,然后使用每个部分有一个单元格的分组表视图.对我来说,这听起来像是实现您所描述的UI类型的最快捷,最简单的方法.
UITableView API文档的相关部分:
@property(nonatomic, readwrite, retain) UIView *backgroundView
...
- (NSInteger)numberOfRowsInSection:(NSInteger)section
Run Code Online (Sandbox Code Playgroud)
和UITableViewDataSource协议:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
34038 次 |
| 最近记录: |