objective-c - iOS画虚线
巴扎黑
巴扎黑 2017-04-17 17:40:46
0
2
678

想在两个控件之间画虚线,有如下代码,不知为何不能画出来;

- (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextBeginPath(context); CGContextSetLineWidth(context, 5.0); CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor); CGFloat lengths[] = {10,10}; CGContextSetLineDash(context, 0, lengths, 5); CGContextMoveToPoint(context, 10.0, 20.0); CGContextAddLineToPoint(context, 310.0,20.0); // CGContextMoveToPoint(context, _strategyImageView1.frame.origin.x + 101, _strategyImageView1.frame.origin.y + 25); // CGContextAddLineToPoint(context, _strategyImageView2.frame.origin.x, _strategyImageView2.frame.origin.y + 25); CGContextStrokePath(context); CGContextClosePath(context); }
巴扎黑
巴扎黑

reply all (2)
巴扎黑

There is nothing wrong with the code itself, you can draw a dotted line

    刘奇

    Will it be covered by other controls? Open the hierarchy page and take a look

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!