我能畫一個虛線框,使用下面的代碼行:繪圖虛線使用的CALayer
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
CGRect shapeRect = CGRectMake(0.0f, 0.0f, 200.0f, 100.0f);
[shapeLayer setBounds:shapeRect];
[shapeLayer setPosition:CGPointMake(self.coreImageView_.frameX, self.coreImageView_.frameBottom - self.coreImageView_.frameHeight/2)];
[shapeLayer setFillColor:[[UIColor clearColor] CGColor]];
[shapeLayer setStrokeColor:[[UIColor whiteColor] CGColor]];
[shapeLayer setLineWidth:2.0f];
[shapeLayer setLineJoin:kCALineJoinRound];
[shapeLayer setLineDashPattern:
[NSArray arrayWithObjects:[NSNumber numberWithInt:5],
[NSNumber numberWithInt:5],
nil]];
現在,如果我想只吸取X點虛線到B點,我應該怎麼修改這個代碼?
你是什麼意思由點X和點B?它們是矩形上的點,還是屏幕上任何地方只有2點? –
可能的重複[here](http://stackoverflow.com/questions/12091916/uiview-with-a-dashed-line) –
http://stackoverflow.com/questions/12091916/uiview-with-a-dashed- line/12092002#12092002 –