1
我想有一個UILabel附加到另一個UIView,目前與AutoLayout鋪設。Swift + Autolayout:旋轉UILabel,保持它旁邊的UIView
我想什麼來實現如下:
但如果我只旋轉視圖,它是圍繞中心點旋轉,如果我改變錨點,上面觀移動。我該如何首先使用自動佈局佈局兩個視圖,然後進行旋轉?
目前,自動佈局將執行以下操作:
用下面的代碼:
label.layer.anchorPoint = CGPoint(x: 0, y: 0)
label.layer.transform = CATransform3DMakeRotation(CGFloat(-45/180.0 * CGFloat(M_PI)), 0, 0, 1)
我得到類似
首先,我認爲你的定位點應爲(0,1),而不是(0 ,0)> https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CoreAnimation_guide/CoreAnimationBasics/CoreAnimationBasics.html(在iOS和OS X中不同)。 –
您的觀點如何附加?通過哪些約束?你不能轉換標籤而不是圖層嗎? –