0
A
回答
3
這應該讓你對你的方式:
- (void)viewDidLoad {
[super viewDidLoad];
UIBezierPath *pth = [UIBezierPath bezierPath];
CGFloat w = 240.0;
CGFloat h = 200.0;
CGPoint p = CGPointZero;
// start at top-left
[pth moveToPoint:p];
// line to top-right
p.x = w;
[pth addLineToPoint:p];
// line to bottom-right
p.y = h;
[pth addLineToPoint:p];
// line to 40 left, 40 up
p.x -= 40;
p.y -= 40;
[pth addLineToPoint:p];
// line to 40 left, 40 down (back to bottom)
p.x -= 40;
p.y += 40;
[pth addLineToPoint:p];
// line to 40 left, 40 up
p.x -= 40;
p.y -= 40;
[pth addLineToPoint:p];
// line to 40 left, 40 down (back to bottom)
p.x -= 40;
p.y += 40;
[pth addLineToPoint:p];
// line to 40 left, 40 up
p.x -= 40;
p.y -= 40;
[pth addLineToPoint:p];
// line to 40 left, 40 down (back to bottom)
p.x -= 40;
p.y += 40;
[pth addLineToPoint:p];
// line to starting point - top-left
[pth closePath];
// 240 x 200 rectangle at 40,40
CGRect r = CGRectMake(40, 40, w, h);
// create a UIView
UIView *v = [[UIView alloc] initWithFrame:r];
v.backgroundColor = [UIColor redColor];
// create a CAShapeLayer
CAShapeLayer *maskShape = [CAShapeLayer layer];
// add the path to the CAShapeLayer
maskShape.path = pth.CGPath;
// set the view's layer mask to the CAShapeLayer
v.layer.mask = maskShape;
// add the masked subview to the view
[self.view addSubview:v];
}
相關問題
- 1. titlebar bottom
- 2. margin-bottom或padding-bottom不工作
- 3. canvas bottom missing uwp
- 4. valign =「bottom」with CSS
- 5. Jquery slideUp bottom page
- 6. UIButton bottom shadow
- 7. ListView Bottom To Top
- 8. NSView OverLaying NSWindow Bottom Bar
- 9. border-bottom dropped whole div
- 10. Scroll Bottom Angularjs指令
- 11. console textarea bottom to top
- 12. javascript-elementFromPoint select bottom element
- 13. 爲什麼在border-bottom-style等於'none'時指定border-bottom-color?
- 14. preg_match,pattern,php
- 15. Castle Windsor&Command Pattern
- 16. NSImage + NSColor + pattern
- 17. Texturebrush with separator pattern
- 18. preg_match url pattern
- 19. Django url pattern
- 20. Lua Pattern Exclusion
- 21. python pattern matching numbers
- 22. Segmented Programatically Pattern
- 23. Gradle Include Pattern
- 24. Git diff pattern
- 25. IRequest/IResponse Pattern
- 26. jQuery中的border-bottom-width
- 27. border-bottom大於文本
- 28. Android/Java - Margin on left/right/bottom
- 29. 在Chrome td border-bottom重疊
- 30. android get tab strip on bottom tabHost
當然 - UIBezierPath作爲掩模(很多很多的容易找到的例子在那裏)。 – DonMag
你可以鏈接一些嗎?或舉一個例子作爲答案?我會接受,如果它的作品:) – Peter
使用paintcode來執行這些任務! –