Create Line in iOS Objective C
Solution:
In iOS you can create a Line using CGContextref.The below code is used for draw a line in a view in x1,y1, is 0,0 and x2,y2 is 20,20.
In iOS you can create a Line using CGContextref.The below code is used for draw a line in a view in x1,y1, is 0,0 and x2,y2 is 20,20.
CGContextRef ctx = UIGraphicsGetCurrentContext();CGRect rect = CGRectMake(0, 0,20,20);CGContextClearRect(ctx, rect);CGContextSetStrokeColorWithColor(ctx, color.CGColor);
CGContextSetLineCap(ctx, kCGLineCapRound);
CGContextSetLineWidth(ctx, 10);
CGContextSetAlpha(ctx, 1);
CGContextMoveToPoint(ctx, 0, 0);CGContextAddLineToPoint(ctx, 20, 20);CGContextStrokePath(ctx);CGContextDrawPath(ctx, kCGPathFillStroke);
Comments
Post a Comment