イメージにボタンがあります。UIView.animateWithDurationを使用して、ビューとイメージビューに新しいサイズを割り当てます。CGRectMakeでUIButtonのサイズを変更する
ビューが正しくスケールアップが、画像表示への変更
コードスニペットはありません:ボタンを押す前に
@IBAction func imageButtonDidTouch(sender: AnyObject) {
UIView.animateWithDuration(0.7) {
/*** Executes Properly ***/
self.dialogView.frame = CGRectMake(0, 0, self.screenWidth!, self.screenHeight!)
/*** Does Not Execute ****/
self.imageButton.frame = CGRectMake(0, 0, self.screenWidth!, 240)
/*** Executes Properly ***/
self.likeButton.hidden = true
self.shareButton.hidden = true
self.userButton.hidden = true
self.headerView.hidden = true
self.dialogView.layer.cornerRadius = 0
}
}
画面の幅と画面H 8
screenWidth = UIScreen.mainScreen().bounds.width
screenHeight = UIScreen.mainScreen().bounds.height
EDIT 1)のviewDidLoad(で定義されている: IMAGEBUTTON宣言
@IBOutlet weak var imageButton: UIButton!
EDIT 2: 私はアニメーション機能に完了ハンドラを追加:
@IBAction func imageButtonDidTouch(sender: AnyObject) {
print("Height Before:", self.imageButton.frame.height)
print("Width Before:",self.imageButton.frame.width)
UIView.animateWithDuration(0.7, animations: {
/*** Executes Properly ***/
self.dialogView.frame = CGRectMake(0, 0, self.screenWidth!, self.screenHeight!)
/*** Does Not Execute ****/
self.imageButton.frame = CGRectMake(0, 0, self.screenWidth!, 240)
/*** Executes Properly ***/
self.likeButton.hidden = true
self.shareButton.hidden = true
self.userButton.hidden = true
self.headerView.hidden = true
self.dialogView.layer.cornerRadius = 0
}) { (true) in
print("Height After:", self.imageButton.frame.height)
print("Width After:",self.imageButton.frame.width)
}
}
無効にする必要がself.imageButtonはnilですか? – Shubhank
No.編集で追加されました –
autolayoutが有効になっていますか? – azimov