현재 서브 뷰로 추가 된 UIView
안에 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
}
감사합니다. 두 번째 또는 세 번째 질문은 이번 주에 저를 도왔습니다. 그것을 비난하십시오. – Geppelt