0
我在iPhone 6上拍攝了一張屏幕截圖,並將其放入iPhone 6模擬器中。我通過呈現一個imagePicker控制器挑選圖像,然後將其設置在didFinishPcikingMediaWithInfo如下:從圖庫照片中導入屏幕截圖並設置爲Xcode 6.3中的背景Swift
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
self.dismissViewControllerAnimated(true, completion: nil);
let refImage = info[UIImagePickerControllerOriginalImage] as! UIImage
self.view.backgroundColor = UIColor(patternImage: refImage)
}
這導致在這樣的顯示:
我還試圖改變最後一行是:
let frame = CGRectMake(0, 0, image.size.width, image.size.height)
let backgroundView = UIImageView(frame: frame)
backgroundView.image = image
backgroundView.contentMode = .ScaleAspectFill
self.view.addSubview(backgroundView)
和還試圖 backgroundView.contentMode = .ScaleAspectFit
任何想法爲什麼截圖的大小加倍,似乎不適合?我猜測某種解決方案問題?