zoukankan      html  css  js  c++  java
  • iOS

    千万别小看UI中得线,否则你的设计师和测试组会无休止地来找你的!!(如果是美女还好,如果是恐龙。。。。)

    在开发中运用最多的是什么,对,表格--TableView,之所以称作表格,是因为他天生带有分割线。

    首先系统带的有如下类型:

    typedef NS_ENUM(NSInteger, UITableViewCellSeparatorStyle) {
        UITableViewCellSeparatorStyleNone,
        UITableViewCellSeparatorStyleSingleLine,
        UITableViewCellSeparatorStyleSingleLineEtched   // This separator style is only supported for grouped style table views currently
    };

    有时你要短点的,如同这样:

    那你可以这样:

     if ([_pinglunTableView respondsToSelector:@selector(setSeparatorInset:)]) {
                UIEdgeInsets insets=UIEdgeInsetsMake(0, 53, 0, 0);
                [_pinglunTableView setSeparatorInset:insets];
            }

    也可以完全自己定义自己想要的分割线,但意味着你要自定义 TableViewCell,然后在自定义UITableViewCell中复写- (void)drawRect:(CGRect)rect方法 如:

    - (void)drawRect:(CGRect)rect
    {
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor); CGContextFillRect(context, rect);//上分割线
         CGContextSetStrokeColorWithColor(context, [UIColor colorWithHexString:@"ffffff"].CGColor);
        CGContextSetStrokeColorWithColor(context, [UIColor colorWithHexString:@"ffffff"].CGColor);
         CGContextSetStrokeColorWithColor(context, [UIColor colorWithHexString:@"e2e2e2"].CGColor);
        CGContextStrokeRect(context, CGRectMake(5, rect.size.height, rect.size.width - 10, 1));//下分割线
        CGContextSetStrokeColorWithColor(context, [UIColor colorWithHexString:@"e2e2e2"].CGColor);
        CGContextStrokeRect(context, CGRectMake(5, rect.size.height, rect.size.width - 10, 1));
    }

    如果要改变颜色,则利用类似[tableView setSeparatorColor:[UIColor redColor]];语句即可修改cell中间分割线的颜色。

    如果UI给你一张图片,那么就可以这样:

    方法一:
    先设置cell separatorColor为clear,然后把图片做的分割线添加到自定义的custom cell上。

    方法二:
    在cell里添加一个像素的imageView后将图片载入进,之后设置tableView.separatorStyle = UITableViewCellSeparatorStyleNone

  • 相关阅读:
    在 ASP.NET 2.0 中上载文件
    ASP.NET(C#)FileUpload实现上传限定类型和大小的文件到服务器<from Copying>
    aspnetupload 上传组件在VS2008中使用详细说明
    基于asp.net 的文件上传和下载~~~转
    设置竖直的分割符【使用div】 (根据屏幕的大小自适应)
    分隔线
    UGUI事件系统
    U3D音频系统
    Unity启动事件-监听:InitializeOnLoad
    VS生成桌面应用程序
  • 原文地址:https://www.cnblogs.com/sixindev/p/4538511.html
Copyright © 2011-2022 走看看