IOS画线条

来源:互联网 发布:百度搜索算法 编辑:程序博客网 时间:2024/05/24 16:13

贴段代码,以备后用。

    UIImageView *textImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 568)];    [self.view addSubview:textImageView];        textImageView.backgroundColor = [UIColor blueColor];        UIGraphicsBeginImageContext(textImageView.frame.size);    CGContextRef context = UIGraphicsGetCurrentContext();    CGContextSetLineWidth(context, 1.0);    CGContextSetRGBStrokeColor(context, 1, 1, 1, 1.0);    CGContextMoveToPoint(context, 0, 100);    CGContextAddLineToPoint(context, 320, 100);    CGContextStrokePath(context);        textImageView.image = UIGraphicsGetImageFromCurrentImageContext();    UIGraphicsEndImageContext();


0 0
原创粉丝点击