2016-11-22 110 views
0

我想在iOS中快速复制图层或视图(一个说跟随和或与跟随者的观点),在红色框中,但我不知道如何处理这个问题。我应该尝试通过制作一个三角形的视图吗?创建一个三角ios swift查看

enter image description here

+0

你知道面膜吗?试着用面具来做 –

+0

这不是一个“教我如何编码”的网站。这是一个获得您编写的代码帮助的网站。你可以用Core Graphics或者CALayers和mask来做到这一点。做一些阅读。 –

+0

谢谢@DuncanC我很欣赏你的意见。 – Aboogie

回答

0

- 尝试下面的代码

import UIKit 

class animationView: UIView { 
override func drawRect(rect: CGRect) { 
let path = UIBezierPath() 
path.moveToPoint(CGPoint(x: 80, y: 50)) 
path.addLineToPoint(CGPoint(x: 140, y:150)) 
path.addLineToPoint(CGPoint(x: 10, y:150)) 
path.closePath() 

UIColor.greenColor().setFill() 
UIColor.redColor().setStroke() 
path.lineWidth = 3 
path.fill() 
path.stroke() 
} 
} 
  • 你应该有这后一个三角形。调整点的x和y值以正确匹配您的要求。