Skip to content
프로젝트

DeveloperLx/LxThroughPointsBezier

GitHub에서 보기

소개

A funny iOS library. Draw a smooth bezier through several points you designated. The curve‘s bend level is adjustable.

웹 및 앱 개발

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

LxThroughPointsBezier

Draw a smooth bezier through several points you designated. The curve‘s bend level is adjustable.

Installation

You only need drag UIBezierPath+LxThroughPointsBezier.h and UIBezierPath+LxThroughPointsBezier.m to your project.

Podfile

pod 'LxThroughPointsBezier', '~> 1.0.0'

Support

Minimum support iOS version: iOS 5.0

How to use

    #import "UIBezierPath+LxThroughPointsBezier.h"

    CGPoint point1 = CGPointMake(30, 180);
    CGPoint point2 = CGPointMake(90, 120);
    CGPoint point3 = CGPointMake(120, 200);
    CGPoint point4 = CGPointMake(160, 240);
    CGPoint point5 = CGPointMake(210, 160);
    CGPoint point6 = CGPointMake(240, 300);
    CGPoint point7 = CGPointMake(290, 140);
    
    NSValue * point1Value = [NSValue valueWithCGPoint:point1];
    NSValue * point2Value = [NSValue valueWithCGPoint:point2];
    NSValue * point3Value = [NSValue valueWithCGPoint:point3];
    NSValue * point4Value = [NSValue valueWithCGPoint:point4];
    NSValue * point5Value = [NSValue valueWithCGPoint:point5];
    NSValue * point6Value = [NSValue valueWithCGPoint:point6];
    NSValue * point7Value = [NSValue valueWithCGPoint:point7];
    
    _pointArray = [NSMutableArray array];
    [_pointArray addObjectsFromArray:@[point1Value, point2Value, point3Value, point4Value, point5Value, point6Value, point7Value]];
    
    _curve = [UIBezierPath bezierPath];
    _curve.contractionFactor = 0.6;
    [_curve moveToPoint:point1];
    [_curve addBezierThroughPoints:_pointArray];
    
    _shapeLayer = [CAShapeLayer layer];
    _shapeLayer.strokeColor = [UIColor blueColor].CGColor;
    _shapeLayer.fillColor = nil;
    _shapeLayer.lineWidth = 3;
    _shapeLayer.path = _curve.CGPath;
    [_view.layer addSublayer:_shapeLayer];

Effect

  • demo

Be careful

The good bend level is about 0.6 ~ 0.8. The default and recommended value is 0.7.
You must wrap CGPoint struct to NSValue object, and give at least 1 point for drawing the curve.

License

LxThroughPointsBezier is available under the Apache License 2.0. See the LICENSE file for more info.

관련 프로젝트 살펴보기

불러오는 중…