制約を使用して別のビューの上でuiviewを回転しようとしています。ここに私が実装したものがあります制約を使用したビューの回転 - Swift
mediaContainer.addSubview(overlayView)
keepBottomLeft()
overlayView.layoutIfNeeded()
func keepBottomLeft(overlayView: UIView) {
NSLayoutConstraint(item: overlayView, attribute:.width, relatedBy:.equal,toItem: mediaContainer, attribute:.width, multiplier: 0.8, constant: 0).isActive = true
NSLayoutConstraint(item: overlayView, attribute:.leading, relatedBy:.equal, toItem: mediaContainer, attribute:.leading, multiplier: 1, constant: 0).isActive = true
NSLayoutConstraint(item: overlayView, attribute:.height, relatedBy:.equal,toItem: nil, attribute:.notAnAttribute, multiplier: 1.0, constant: 26).isActive = true
NSLayoutConstraint(item: overlayView, attribute:.bottom, relatedBy:.equal, toItem: mediaContainer, attribute:.bottom, multiplier: 1, constant: 0).isActive = true
overlayView.transform = CGAffineTransform(rotationAngle: CGFloat(-M_PI_2))
}
アンカーポイントを使用する必要がありますか?これは私が達成しようとしていることですか?
私は何を取得することは
で誰かが正しい方向に私を指すことができますか?
あなたが実際にあなたのビューは、あなたの第二の画像にあなたの最初の画像から連続的に回転しますか? (したがって、それは、2番目の画像のように垂直になるまで、斜めに傾きます) –
ここで回転をアニメーション化していません。 IBActionの新しい位置に移動するだけです。 –
ビューの内容を90°回転させるか、高さと幅を入れ替えてアンカーポイントを調整しますか? –