iphone - 如何创建好看的UITableView分隔符?

标签 iphone objective-c uitableview

基本分隔符看起来非常简单并且是一维的,但是大多数表格 View 都有一个好看的分隔符,我认为它看起来不错,因为它有阴影或使它看起来像 3D 的东西。他们是怎么做到的?

最佳答案

您可以通过编程/XIB 创建表。 现在在您的代码或 XIB 集中:

yourTable.separatorStyle=UITableViewCellSeparatorStyleNone;  

现在在 TableView 委托(delegate)方法中:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {  
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Identifier];
    if (cell == nil) 
    {

        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:businessLogicIdentifier]
                autorelease];


        customSeperator=[[UIView alloc]initWithFrame:CGRectMake(0, (cell.frame.origin.y), 320, 1)];
        customSeperator.backgroundColor=[UIColor lightGrayColor];

        [cell.contentView addSubview:customSeperator];  
}  

现在在行 (customSeperator.backgroundColor=[UIColor lightGrayColor];) 你也可以尝试

[UIColor colorWithPatternImage:[UIImage imageNamed:@"myimage.png"]];  

用于使用您自己的图像。 希望对您有帮助

关于iphone - 如何创建好看的UITableView分隔符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10206909/

相关文章:

c# - Iphone,从 MonoTouch 获取国家列表

objective-c - 对可能被objective-c中的另一个线程锁定的对象执行 "dirty read"的最佳方法

iphone - UITableView节头为 'Floating'时可以更改吗?

iphone - 如何知道谁是第一响应者?

iphone - iOS : Image get rotated 90 degree after saved as PNG representation data

Iphone 负载 XIB/m/h 问题

ios - IOS SDK中下载多张图片时如何显示加载进度

objective-c - NSToolBar 带有两个自定义按钮

ios - 当我给UIImageView动画时,为什么UIImage引用会更改?

ios - UITableView 动态动画(beginUpdates/endUpdates)有时会因不一致而崩溃