0
目前我在UIView
中有一個Method
,它已被添加爲子視圖。我想知道如何保留Method的屬性,使其框架規定UIView
的大小。將UIView框架綁定到另一個類中的方法框架
NSObject的:
public class func drawCanvas1(frame frame: CGRect = CGRect(x: 0, y: 0, width: 86, height: 31)) {
let rectanglePath = UIBezierPath(rect: CGRect(x: frame.minX + frame.width - 86, y: frame.minY + floor((frame.height) * 0.00000 - 0.5) + 1, width: 86, height: frame.height - 1 - floor((frame.height) * 0.00000 - 0.5)))
UIColor.grayColor().setFill()
rectanglePath.fill()
}
的UIView:
class shapeTestUI: UIView {
override func drawRect(rect: CGRect) {
StyleKitName.drawCanvas1()
}
}
視圖控制器:
var block1: shapeTestUI = shapeTestUI()
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = UIColor(red: 38.0/255, green: 151.0/255, blue: 68.0/255, alpha: 1)
let block = createBlock(block1)
self.view.addSubview(block)
}
func createBlock(blocks:UIView) -> UIView {
let block = blocks as UIView!
//block.frame = CGRectMake(0, 0, 50, 50)
return block
}
謝謝,艾克。本週您幫助我的第二或第三個問題。 Apreciate它。 – Geppelt