###コードでUIButtonの配置したいです。
コードでUI部品を配置したいのですが、まず何を書いたらいいか、わかりません。
コードでのUIButton配置の仕方を教えてもらえませんか?
後、StoryBoardを使わない方法でアプリ製作できる参考書やサイトなども教えてもらえないでしょうか?
最後の質問はたくさんの方から意見が聞きたいので、最後の質問だけでもいいのでお答えしてもらいたいです。
よろしくお願いします!!
import UIKit
class ViewController: UIViewController {
let button: UIButton = { let button = UIButton() button.frame = CGRect(x:110,y:100,width:100,height:30) button.setTitle("タイトルです", for: .normal) button.setTitleColor(.black, for: .normal) button.setBackgroundImage(UIImage(named: "grayButton"), for: UIControlState.normal) return button }() override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .blue view.addSubview(button) ** //ここに何を書けばいいのでしょうか?** } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() }
}
回答1件
あなたの回答
tips
プレビュー