본문 바로가기

Development/IOS & Mac

[IOS] UIView 점선 테두리 그리기

CAShapeLayer *layer = [CAShapeLayer layer];

[layer setStrokeColor:[[UIColor colorWithRed:0.86 green:0.86 blue:0.83 alpha:1] CGColor]];

[layer setFillColor:[[UIColor clearColor] CGColor]];

[layer setLineWidth:3];

[layer setLineDashPattern:[NSArray arrayWithObjects:[NSNumber numberWithInt:5], [NSNumber numberWithInt:3], nil]];

[layer setPath:[UIBezierPath bezierPathWithRoundedRect:self.drawingPlaceView.bounds cornerRadius:15].CGPath];

[layer setBounds:self.drawingPlaceView.bounds];

[layer setPosition:CGPointMake(size.width/2, size.height/2)];

[layer setLineCap:kCALineCapRound];

[view.layer addSublayer:layer];


CAShapeLayer를 만든후 View에 적용하면 된다.