Skip to content

Instantly share code, notes, and snippets.

@hachinobu
Last active August 29, 2015 14:19
Show Gist options
  • Save hachinobu/d959ea929a7352fe1bef to your computer and use it in GitHub Desktop.
Save hachinobu/d959ea929a7352fe1bef to your computer and use it in GitHub Desktop.
点線を引く
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