class ViewController: UIViewController {
var subView = UIView() var subView2 = UIView() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. let origin = CGPoint(x: 100, y: 100) let size = CGSize(width: 50, height: 50) let frame = CGRect(origin: origin, size: size) subView.frame = frame subView.backgroundColor = .red view.addSubview(subView) let origin2 = CGPoint(x: 100, y: 100) let size2 = CGSize(width: 50, height: 50) let frame2 = CGRect(origin: origin2, size: size2) subView2.bounds = frame2 subView2.backgroundColor = .red view.addSubview(subView2) }
}
subView.frame = frameとsubView2.bounds = frame2において、位置の数値は同じ指定なのにな
frameかboundsの指定の違いでなぜ違いが出るのでしょうか?
ご参考まで。
https://selection9.blogspot.com/2016/06/uiviewframebounds.html
あなたの回答
tips
プレビュー