UIBezierPathベッセル弧
1977 ワード
次の2つのページは私が勉強している間に発見した関連知識のページで、よく使われている知識点をまとめました.忘れないように、ここに特記します.UIBezierPathベッセルアークの一般的な方法iOS UIBezierPathクラスの紹介
いくつか注意してください:描画した図形はdrawRect関数に書き、Viewで図形を描画します.
以下はUIBezierPathに詳しいいくつかの小さな例です.ここに置いておきましょう.後で補充します.
いくつか注意してください:描画した図形はdrawRect関数に書き、Viewで図形を描画します.
以下はUIBezierPathに詳しいいくつかの小さな例です.ここに置いておきましょう.後で補充します.
//
// XXCycleView.m
// XXGraphics
//
// Created by shine on 2016/12/22.
// Copyright © 2016 shine. All rights reserved.
//
#import "XXCycleView.h"
@implementation XXCycleView
- (void)drawRect:(CGRect)rect {
// Drawing code
//
//[self setupCycle];
//
//[self triAngle];
//
[self quadCurve];
}
- (void)quadCurve{
UIBezierPath *path = [UIBezierPath bezierPath];
UIColor *lineColor = [UIColor blackColor];
[lineColor set]; //
[path moveToPoint:CGPointMake(100, 100)]; //
// ,
[path addQuadCurveToPoint:CGPointMake(200, 100) controlPoint:CGPointMake(150, 50)];
[path stroke];
}
- (void)triAngle{
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:self.center];
UIColor *linecolor = [UIColor blackColor];
CGFloat width = 5;
[linecolor set];
path.lineWidth = width;
//
CGPoint point2 = CGPointMake(200, 200);
//
CGPoint point3 = CGPointMake(300, 300);
[path addLineToPoint:point2];
[path addLineToPoint:point3];
[path closePath];
[path stroke];
}
- (void)setupCycle{
//
//
CGPoint cyclePoint = self.center;
//
CGFloat radius = 100;
UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:cyclePoint radius:radius startAngle:0 endAngle:M_PI clockwise:NO];
UIColor *linecolor = [UIColor blackColor];
path.lineWidth = 5;
//[linecolor set];
[linecolor setStroke];
UIColor *fillColor = [UIColor redColor];
[fillColor setFill];
[path stroke];
[path fill];
}
@end