将Square UIView划分为横截面iOS Objective C
Posted
技术标签:
【中文标题】将Square UIView划分为横截面iOS Objective C【英文标题】:Divide Square UIView into Cross Sections iOS Objective C 【发布时间】:2017-05-04 05:44:44 【问题描述】:我有一个方形 UIView,我需要将其分成具有两种不同颜色的横截面,如图所示
【问题讨论】:
在视图上添加一个图层并赋予它们不同的颜色。要塑造您的图层,请使用贝塞尔路径。 你能详细说明一下吗..!!? 引用here 【参考方案1】:这是我实现该图的代码:
//Define the drawing path
UIBezierPath *path1 = [[UIBezierPath alloc] init];
//path Move to start drawing position
[path1 moveToPoint:CGPointMake(200, 100)];
//Draw a straight line from the starting position to(100, 200)
[path1 addLineToPoint:CGPointMake(100, 100)];
//To draw a line from (100, 200) to (200, 200)
[path1 addLineToPoint:CGPointMake(100, 200)];
//close path
[path1 closePath];
CAShapeLayer *layer1 = [[CAShapeLayer alloc] init];
layer1.path = path1.CGPath;
layer1.fillColor = [UIColor colorWithRed:0.88 green:0.87 blue:0.87 alpha:1.0].CGColor;
[self.view.layer addSublayer:layer1];
UIBezierPath *path2 = [[UIBezierPath alloc] init];
[path2 moveToPoint:CGPointMake(200, 100)];
[path2 addLineToPoint:CGPointMake(200, 200)];
[path2 addLineToPoint:CGPointMake(100, 200)];
[path2 closePath];
CAShapeLayer *layer2 = [[CAShapeLayer alloc] init];
layer2.path = path2.CGPath;
layer2.fillColor = [UIColor colorWithRed:0.89 green:0.57 blue:0.53 alpha:1.0].CGColor;
[self.view.layer addSublayer:layer2];
结果如下: result image
【讨论】:
以上是关于将Square UIView划分为横截面iOS Objective C的主要内容,如果未能解决你的问题,请参考以下文章
09 | Android 高级进阶(源码剖析篇) Square 高效易用的 IO 框架 okio
通过添加其他横截面将 pandas MultiIndex 的横截面设置为 DataFrame