zoukankan      html  css  js  c++  java
  • 在imageView上画线(转)

    前提:CoreGraphics.framework

    - (void)viewDidLoad {  
        [super viewDidLoad];  
       
        UIImageView *imageView=[[UIImageView alloc] initWithFrame:self.view.frame];  
        [self.view addSubview:imageView];  
       
        self.view.backgroundColor=[UIColor blueColor];  
       
        UIGraphicsBeginImageContext(imageView.frame.size);  
        [imageView.image drawInRect:CGRectMake(0, 0, imageView.frame.size.width, imageView.frame.size.height)];  
        CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);  
        CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 15.0);  //线宽
        CGContextSetAllowsAntialiasing(UIGraphicsGetCurrentContext(), YES);  
        CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0);  //颜色另有UIColor转为RGB方法见博客  
        CGContextBeginPath(UIGraphicsGetCurrentContext());  
        CGContextMoveToPoint(UIGraphicsGetCurrentContext(), 100, 100);  //起点坐标
        CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), 200, 100);   //终点坐标
        CGContextStrokePath(UIGraphicsGetCurrentContext());  
        imageView.image=UIGraphicsGetImageFromCurrentImageContext();  
        UIGraphicsEndImageContext();  
    }  
  • 相关阅读:
    入门指引之永久素材
    入门指引之上传临时素材
    入门指引之查看accesstoken
    java中的左移 右移
    病狗问题
    leetcode 几何题 位运算 面试编程
    CNN网络参数
    python学习整理
    JAVA问题整理
    计算机网络整理
  • 原文地址:https://www.cnblogs.com/sunmair/p/6018914.html
Copyright © 2011-2022 走看看