CGRect r = [[UIScreen mainScreen] applicationFrame];
UIImageView *imageView=[[UIImageView alloc] initWithFrame:self.view.frame];
[self.view addSubview:imageView];
UIGraphicsBeginImageContext(imageView.frame.size);
[imageView.image drawInRect:CGRectMake(0, 0, imageView.frame.size.width, imageView.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 1.0); //线宽
CGContextSetAllowsAntialiasing(UIGraphicsGetCurrentContext(), YES);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.5, 0.5, 0.5, 1.0); //颜色
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), 10, CGRectGetMaxY(self.openSwitch.frame)+15); //起点坐标
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), r.size.width-10, CGRectGetMaxY(self.openSwitch.frame)+15); //终点坐标
CGContextStrokePath(UIGraphicsGetCurrentContext());
imageView.image=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
iOS 画一条分割线
最新推荐文章于 2018-03-22 19:26:49 发布