zoukankan      html  css  js  c++  java
  • iOS 学习

    //绘制虚线
    -(void)set{
        
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 100, 320, 20)];
        [self.view addSubview:imageView];
        //创建一个基于位图的上下文,大小为 imageView 的大小
        UIGraphicsBeginImageContext(imageView.frame.size);
        //绘图位置,相对画布顶点而言
        [imageView.image drawInRect:CGRectMake(0, 0, imageView.frame.size.width, imageView.frame.size.height)];
        //设置端点的格式
        CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapSquare);//绘制方形端点
        //{10,10} 表示先绘制 10 个点,再跳过 10 个点,重复。。。
        //{10,20,10} 表示先绘制 10 个,跳过 20 个,绘制 10 个点,跳过 10 个,绘制 20 个,重复。。相应的 count 要等于lengths 的个数
        CGFloat lengths[] = {10,10};
        CGContextRef line = UIGraphicsGetCurrentContext();
        //虚线的颜色
        CGContextSetStrokeColorWithColor(line, [UIColor redColor].CGColor);
        //phase 表示绘制的时候跳过多少个点
        CGContextSetLineDash(line, 0, lengths, 2);
        //绘制的起点
        CGContextMoveToPoint(line, 0.0, 20);
        //终点
        CGContextAddLineToPoint(line, 310, 20);
        //画线
        CGContextStrokePath(line);
        
        imageView.image = UIGraphicsGetImageFromCurrentImageContext();
    }
  • 相关阅读:
    正睿提高组2017模拟题三T1
    数位dp【转载】
    正睿提高组2017模拟题二T2
    【树状数组二维区间加+区间查询模板】bzoj3132
    【树状数组区间加+区间查询模板】洛谷P3372
    51Nod
    CodeForces 631E Product Sum
    CodeForces
    [不知道哪来的题] 完美理论
    CodeForces
  • 原文地址:https://www.cnblogs.com/asamu/p/5580877.html
Copyright © 2011-2022 走看看