私のアプリケーションのページに簡単な更新ボタンを追加しています。ボタンにはimageViewがあり、ビューの上に「今すぐ更新」というタイトルが必要です。Swift 3.0 - UIButtonラベルの高さに高さがあります
私はUILabelをUIButtonのサブビューとして見ることができます。しかし、UILabelの説明を印刷するフレーム
(250 20; 283 0).
を返します。これは私のコード
let updateButton = UIButton()
updateButton.frame = CGRect(x: centreX(parent: self.view, width: 150), y: 200, width: 150, height: 40)
updateButton.setImage(UIImage(named:"my-image"), for: .normal)
updateButton.setTitle("Update Now", for: .normal)
updateButton.titleLabel?.sizeToFit()
updateButton.titleLabel?.frame = updateButton.frame
updateButton.setTitleColor(UIColor.black, for: .normal)
self.view.addSubview(updateButton)
である私はライン
updateButton.titleLabel?.sizeToFit()
updateButton.titleLabel?.frame = updateButton.frame
の両方がラベルのフレームの高さを変更するだろうと思いました。私がここに欠けているものはありますか?
スウィフト3.0およびiOSの10
はい、ありがとうございます。これは私の間違いでしたが、コードをコピーしてイメージの実際の名前を削除するように変更しました。 – ochhii