"001 UILabelで文字を表示" iOS app開発 習得日記 (5)
UIkitを覚えるために
こちらの写経がいいときいたので始めた
(http://docs.fabo.io/swift/uikit/001_uilabel.html)
001 UILabelで文字を表示
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let bWidth: CGFloat = 200
let bHeight: CGFloat = 50
let posX: CGFloat = self.view.bounds.width/2 - bWidth/2
let posY: CGFloat = self.view.bounds.height/2 - bHeight/2
let label: UILabel = UILabel(frame: CGRect(x: posX, y: posY, width: bWidth, height: bHeight))
label.backgroundColor = UIColor.orange
label.layer.masksToBounds = true
label.layer.cornerRadius = 20.0
label.shadowColor = UIColor.gray
label.textAlignment = NSTextAlignment.center
self.view.backgroundColor = UIColor.cyan
self.view.addSubview(label)
}
}
selfは、ViewControllerのインスタンスを表しているのでよいのか?
また、
label.layer.masksToBounds
とドットを続けて書いているところがわからない。
labelインスタンスの layerプロパティのmasksToboundsプロパティということ?
プロパティのプロパティ?
どういうこと?
Author And Source
この問題について("001 UILabelで文字を表示" iOS app開発 習得日記 (5)), 我々は、より多くの情報をここで見つけました https://qiita.com/shutainer/items/7d6382f6f6ef7fa5caed著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .