0
我想在UIView的中心放置一條直線。在表格視圖單元格中查找UIView的x位置
override func draw(_ rect: CGRect) {
if let anchor = anchorView(){
print("Anchor x origin : \(anchor.bounds.origin.x)")
anchor.backgroundColor = UIColor.blue
timeline.start = CGPoint(x: anchor.bounds.origin.x + anchor.frame.width/2 , y: 0)
timeline.middle = CGPoint(x: timeline.start.x, y: anchor.frame.origin.y)
timeline.end = CGPoint(x: timeline.start.x, y: self.bounds.size.height)
timeline.draw(view: self.contentView)
}else{
print("this should not happen")
}
}
我收到的UIView x位置等於零
你可以設置x po sview of line like yourview.frame.size.origin.x + yourview.frame.size.width/2 –
我得到這個錯誤:「CGSize類型的值沒有成員'起源' –