io sono principiante allo sviluppo iOS quindi vorrei condividere tutta l'informazioni che ho avuto in questa sezione.
Prima dalle risorse immagine (images.xcassets) creare il set di immagini.
Secondo Documentation qui è tutte le dimensioni devono creare immagine di sfondo.
For iPhone 5:
640 x 1136
For iPhone 6:
750 x 1334 (@2x) for portrait
1334 x 750 (@2x) for landscape
For iPhone 6 Plus:
1242 x 2208 (@3x) for portrait
2208 x 1242 (@3x) for landscape
iPhone 4s (@2x)
640 x 960
iPad and iPad mini (@2x)
1536 x 2048 (portrait)
2048 x 1536 (landscape)
iPad 2 and iPad mini (@1x)
768 x 1024 (portrait)
1024 x 768 (landscape)
iPad Pro (@2x)
2048 x 2732 (portrait)
2732 x 2048 (landscape)
chiamata l'immagine sfondo possiamo chiamare immagine da attività di immagine utilizzando questo metodo UIImage(named: "background")
qui è il codice completo esempio
override func viewDidLoad() {
super.viewDidLoad()
assignbackground()
// Do any additional setup after loading the view.
}
func assignbackground(){
let background = UIImage(named: "background")
var imageView : UIImageView!
imageView = UIImageView(frame: view.bounds)
imageView.contentMode = UIViewContentMode.ScaleAspectFill
imageView.clipsToBounds = true
imageView.image = background
imageView.center = view.center
view.addSubview(imageView)
self.view.sendSubviewToBack(imageView)
}
fonte
2016-03-30 13:13:25
È alla ricerca di [UIColor.colorWithPatternImage] (https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIColor_Class/index.html#// apple_ref/OCC/CLM/UIColor/colorWithPatternImage :)? Maggiori informazioni sull'immagine di sfondo per UIView [qui] (http://beageek.biz/how-to-set-background-image-uiview/) – Xenyal