IOS绘制虚线的方法,可以给cell设置虚线分割线
2016-11-19 17:25
417 查看
.h文件
@interface BaseLineView : UIView @end
.m文件
@implementation BaseLineView - (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { [self setBackgroundColor:[UIColor whiteColor]]; } return self; } - (void)drawRect:(CGRect)rect { CGContextRef cont = UIGraphicsGetCurrentContext(); CGContextSetStrokeColorWithColor(cont, [UIColor colorWithHexString:@"CFD3D2"].CGColor); // 设置线宽 CGContextSetLineWidth(cont, 4); // lengths的值{3,3}表示先绘制3个点,再跳过3个点,如此反复 CGFloat lengths[] = {3,3}; CGContextSetLineDash(cont, 0, lengths, 2); //画虚线 CGContextBeginPath(cont); CGContextMoveToPoint(cont, 0.0, rect.size.height - 1); //开始画线 CGContextAddLineToPoint(cont, kScreenW, rect.size.height - 1); CGContextStrokePath(cont); } @end
相关文章推荐
- iOS 8下设置cell的分割线缩进separatorInset
- iOS 关于tableView cell的分割线的一些设置
- IOS绘制虚线的方法总结
- iOS开发中设置UITableView每组头试图与第一行cell之间的分割线
- 详解iOS开发中UITableview cell 顶部空白的多种设置方法
- 【iOS】UITableview cell 顶部空白的n种设置方法
- IOS uitableview中cell的分割线设置距离,并且去掉cell的边框,要不然多了一条细线
- iOS 8下设置cell的分割线缩进separatorInset
- iOS-自定义TextView的方法,可以设置占位文字(placeholder)又可滚动
- iOS代码规范~系统相册、导航栏标题、cell设置分割线、图层
- iOS开发小技巧--设置cell左右有空隙,设置分割线的新思路,重写setFrame:让别人在外界无法修改控件的大小
- iOS 绘制虚线的三种方法
- ios开发解决cell的分割线左侧部分缺失的方法
- 详解iOS开发中UITableview cell 顶部空白的多种设置方法
- iOS小技巧-UITableView去除底部多余的分割线方法以及设置分割线风格和颜色
- iOS 关于tableView cell的分割线的一些设置
- 干掉iOS中的UITbleViewCell分割线偏移的方法
- iOS 关于tableView cell的分割线的一些设置
- [iOS 绘制虚线] 转: iOS 绘制虚线的三种方法
- IOS TableViewCell分割线设置和隐藏多余cell