Warning: Undefined array key 2 in /home/naoooooo8/naoya-ono.com/public_html/blog/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 15
Warning: Undefined array key 3 in /home/naoooooo8/naoya-ono.com/public_html/blog/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 18
Warning: Undefined array key 4 in /home/naoooooo8/naoya-ono.com/public_html/blog/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 21
Warning: Undefined array key 2 in /home/naoooooo8/naoya-ono.com/public_html/blog/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 27
Warning: Undefined array key 3 in /home/naoooooo8/naoya-ono.com/public_html/blog/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 30
Warning: Undefined array key 4 in /home/naoooooo8/naoya-ono.com/public_html/blog/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 33
UIViewやUIImageなどのUI部品をコードを書いて画面いっぱいに広げる方法を紹介します。
書き方
UIの変数名.frame = CGRect(x : 0, y : 0, width : self.view.frame.width, height : self.view.frame.height)
例
coverViewというUIViewを用意しておき、それを画面いっぱいに広げる。
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var coverView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
// coverViewを画面いっぱいに広げる
coverView.frame = CGRect(x : 0, y : 0, width : self.view.frame.width, height : self.view.frame.height)
}
}
self.view.frame.width と self.view.frame.heightでスクリーンの幅と高さが取得できるので、デバイスのサイズに関係なく、スクリーンいっぱいに広げることができます。



