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. iOS - UIView border-bottom-width?
- 2. bottom bottom rails應用協會
- 3. titlebar bottom
- 4. 輪EGDE添加到地圖標記
- 5. margin-bottom或padding-bottom不工作
- 6. Trasition border-bottom?
- 7. mCustomScrollbar SCROL BOTTOM
- 8. UIButton bottom shadow
- 9. html float bottom
- 10. bottom-top TileLayout
- 11. ListView Bottom To Top
- 12. Jquery slideUp bottom page
- 13. CSS row border bottom
- 14. valign =「bottom」with CSS
- 15. canvas bottom missing uwp
- 16. FragmentTabHost bottom TabWidget
- 17. Cahining pattern
- 18. 在@Pattern
- 19. 有什麼問題:Pattern pattern = Pattern.compile(「\\」);
- 20. Flexbox Force Scroll To Bottom
- 21. javascript-elementFromPoint select bottom element
- 22. TCPDF set bottom margin zero
- 23. console textarea bottom to top
- 24. layout_gravity =「bottom」不工作
- 25. border-bottom dropped whole div
- 26. Scroll Bottom Angularjs指令
- 27. NSView OverLaying NSWindow Bottom Bar
- 28. Javascript to to padding-bottom
- 29. android fit panel to bottom
- 30. 爲什麼在border-bottom-style等於'none'時指定border-bottom-color?
當然 - UIBezierPath作爲掩模(很多很多的容易找到的例子在那裏)。 – DonMag
你可以鏈接一些嗎?或舉一個例子作爲答案?我會接受,如果它的作品:) – Peter
使用paintcode來執行這些任務! –