cashapelayer

Sine CAShapeLayer as a mask of CALayer

一笑奈何 提交于 2019-12-21 16:51:15
问题 I'm trying to implement the next curious thing: I have a few dots and I'd like to link them with sine waves Next method returns the array of dots for making plot: - (NSArray *)plotPointsBetweenPoint:(CGPoint)pointA andPoint:(CGPoint)pointB { double H = fabs(pointB.y - pointA.y); double L = fabs(pointB.x - pointA.x); NSInteger granularity = 40; NSMutableArray *array = [NSMutableArray arrayWithCapacity:granularity + 1]; for (int i = 0; i <= granularity; ++i) { CGFloat x = M_PI*(float)i/

CAShapeLayer strokeStart and strokeEnd positions

我与影子孤独终老i 提交于 2019-12-21 15:08:36
问题 I have this piece of code: let arcPath = UIBezierPath(ovalInRect: CGRectMake(0, 0, frame.width, frame.height)) circleLayer = CAShapeLayer() circleLayer.path = arcPath.CGPath circleLayer.fillColor = UIColor.clearColor().CGColor circleLayer.strokeColor = UIColor.blueColor().CGColor circleLayer.lineWidth = 5.0; circleLayer.strokeStart = 0 circleLayer.strokeEnd = 0.7 which results like this: As you can see, the arc starts on the right side of the circle. I would like to draw the arc starting from

CAShapeLayer shadow

妖精的绣舞 提交于 2019-12-21 05:44:18
问题 Given the following CAShapeLayer is it possible to add a drop shadow like the following image at the tip? I'm using a UIBezierPath to draw the bars. - (CAShapeLayer *)gaugeCircleLayer { if (_gaugeCircleLayer == nil) { _gaugeCircleLayer = [CAShapeLayer layer]; _gaugeCircleLayer.lineWidth = self.gaugeWidth; _gaugeCircleLayer.fillColor = [UIColor clearColor].CGColor; _gaugeCircleLayer.strokeColor = self.gaugeTintColor.CGColor; _gaugeCircleLayer.strokeStart = 0.0f; _gaugeCircleLayer.strokeEnd =

How to give cornerRadius for UIBezierPath

白昼怎懂夜的黑 提交于 2019-12-21 04:45:07
问题 I created a rectangle using following code and now I need to rounded the corners of this rectangle. but I can't find a property called layer.cornerRadius, can anyone help me ? class OvalLayer: CAShapeLayer { let animationDuration: CFTimeInterval = 0.3 override init() { super.init() fillColor = Colors.green.CGColor path = ovalPathSmall.CGPath } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } var ovalPathStart: UIBezierPath { let path =

Need a tip with UIBezierPath. Triangle Shape like Instagram Sign Up View

非 Y 不嫁゛ 提交于 2019-12-21 02:55:14
问题 I'm trying to create a bezier path like the instagram triangle in the picture below, however I must be doing something wrong. The Bezier path does not show! - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. } -(void)viewDidLayoutSubviews{ [super viewDidLayoutSubviews]; [self drawTriangle]; } - (IBAction)closeButton:(UIButton *)sender { [self dismissViewControllerAnimated:YES completion:nil]; } - (void)drawTriangle{ UIBezierPath* trianglePath =

iOS: UIBezierPath and CAShapeLayer fillRule

六眼飞鱼酱① 提交于 2019-12-20 10:59:08
问题 I have used both UIBezierPath and CAShapeLayer before. But almost every time in conjunction with filling the object contained within the path with color inside. But I would like this time to fill the color outside of the object contained by the UIBezierPath . I just wrote and ran the following simple code trying to get myself acquainted with the fillRule property: CAShapeLayer *myLayer = (CAShapeLayer*) self.layer; //size: 320 X 480 UIBezierPath *testPath = [UIBezierPath

CALayer vs CGContext, which is a better design approach?

夙愿已清 提交于 2019-12-20 10:37:17
问题 I have been doing some experimenting with iOS drawing. To do a practical exercise I wrote a BarChart component. The following is the class diagram (well, I wasnt allowed to upload images) so let me write it in words. I have a NGBarChartView which inherits from UIView has 2 protocols NGBarChartViewDataSource and NGBarChartViewDelegate. And the code is at https://github.com/mraghuram/NELGPieChart/blob/master/NELGPieChart/NGBarChartView.m To draw the barChart, I have created each barChart as a

CAShapeLayer mask view

纵然是瞬间 提交于 2019-12-20 04:30:10
问题 I have one problem. I look for the answers on the net and I don't understand why is not working. I must do some stupid mistake which I can't figure it out. if I make : - (void)viewDidLoad { [super viewDidLoad]; UIView * view = [[UIView alloc]initWithFrame:CGRectMake(10, 10, 300, 400)]; view.backgroundColor = [UIColor blueColor]; [self.view addSubview:view]; } it create blue view on the screen, but if I make - (void)viewDidLoad { [super viewDidLoad]; UIView * view = [[UIView alloc

Get position of path at time

心已入冬 提交于 2019-12-19 08:00:53
问题 is there a nice way to calculate the position of a path (CGPath or UIBezierPath) at a given time (from 0 to 1)? Using CAShapeLayer for example, one can create an animated stroke end. I want to know the position of that stroke end at arbitrary times. Thanks in advance, Adrian 回答1: You can definitely base your approach on the CADisplayLink and a tracking layer. However, if you don't mind doing a little bit of math on your own, the solution is not too complicated. Plus, you wont have to depend

how to draw CALayer with line path like simulate eraser effect?

落爺英雄遲暮 提交于 2019-12-18 13:48:07
问题 I want to simulate eraser effect with touch event to show a image that behind something block on top, eg, gray color; Something like that: I have find for a long time for the solution but I can't do it well. following is my custom view code: CustomView.m: -(id)initWithCoder:(NSCoder *)aDecoder { if (self = [super initWithCoder:aDecoder]) { [self setup]; } return self; } -(id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self setup]; } return self; } -(void