LoginSignup
0
1

More than 3 years have passed since last update.

全ての端末に対応するための CGRect Swift 編

Posted at

すべの端末に対応する、Viewportタグを、Swiftで作る

CGRectでこのようになります。

まず、オブジェクトをパーツとして、アウトレット接続します。それからコードを作ります。

view1.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height)

button1.frame = CGRect(x: 10, y: self.view.frame.size.height/2-120, width: self.view.frame.size.width-20, 44)

まず、内容は、フレーム(入れ子)の、CGRect、いわゆる、CGRect(x: 左からの位置, y: 上からの位置, width: 幅, height: 高さ)
を、自身のフレームを指す、self その view とその frame size width/height で X、Yでは、開始位置が、右から、下から、Width、Heightでは、幅、高さ、いっぱいからの、マイナス数値などで構成されるもので、htmlで言うところの、viewport タグである。   

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1