您的位置:首页 > 移动开发 > IOS开发

iOS画虚线

2015-12-17 09:31 260 查看
- (UIImage *)dashLineImage:(CGSize)size
{
    CGFloat lengths[] = {3,
2};
    UIGraphicsBeginImageContext(size);
    CGContextRef context =
UIGraphicsGetCurrentContext();
    CGContextBeginPath(context);
    CGContextSetLineWidth(context, size.height);
    CGContextSetStrokeColorWithColor(context, [UIColor
grayColor].CGColor);
    CGContextSetLineDash(context,
0, lengths, 2);
    CGContextMoveToPoint(context,
0, 0);
    CGContextAddLineToPoint(context, size.width,
0);
    CGContextStrokePath(context);
    CGContextClosePath(context);
    UIImage *image =
UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios 虚线