画一条虚线 ————————————————

下面是来客网 jb51.cc 通过网络收集整理的代码片段。

来客网小编现在分享给大家,也给大家做个参考。

 UIImageView *imageView1 = [[UIImageView alloc]initWithFrame:CGRectMake(0,200,320,20)];
    [self.view addSubview:imageView1];
    
    
    UIGraphicsBeginImageContext(imageView1.frame.size);   //开始画线
    [imageView1.image drawInRect:CGRectMake(0,imageView1.frame.size.width,imageView1.frame.size.height)];
    CGContextSetLineCap(UIGraphicsGetCurrentContext(),kCGLineCapRound);  //设置线条终点形状
    
    
    const CGFloat lengths[] = {5,3};
    CGContextRef line = UIGraphicsGetCurrentContext();
    CGContextSetStrokeColorWithColor(line,[UIColor redColor].CGColor);
    
    CGContextSetLineDash(line,lengths,2);  //画虚线
    CGContextMoveToPoint(line,0.0,20.0);    //开始画线
    CGContextAddLineToPoint(line,310.0,20.0);
    CGContextStrokePath(line);
    
    imageView1.image = UIGraphicsGetImageFromCurrentImageContext();

以上是来客网(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。

以上是来客网为你收集整理的画一条虚线 ————————————————全部内容,希望文章能够帮你解决画一条虚线 ————————————————所遇到的程序开发问题。

如果觉得来客网网站内容还不错,欢迎将来客网网站推荐给程序员好友。