Last active
August 29, 2015 14:19
-
-
Save hachinobu/d959ea929a7352fe1bef to your computer and use it in GitHub Desktop.
点線を引く
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIViewの継承クラス | |
- (void)drawRect:(CGRect)rect { | |
// Drawing code | |
UIBezierPath *path = [UIBezierPath bezierPath]; | |
// 線の色を設定 | |
[[UIColor colorWithRed:151.0/255.0 green:151.0/255.0 blue:151.0/255.0 alpha:1.0] set]; | |
// 線の太さを設定 | |
[path setLineWidth:1.0f]; | |
// 点線のパターンを設定 | |
// 5px線を描き、7px空白にする | |
CGFloat dashPattern[] = {5.0f, 7.0f}; | |
[path setLineDash:dashPattern count:2 phase:0]; | |
// 始点に移動 | |
[path moveToPoint:CGPointZero]; | |
// 点線を描いていく | |
[path addLineToPoint:CGPointMake(self.frame.size.width, 0)]; | |
[path stroke]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment