0
我試圖做一個應用程序,用戶可以從他們的圖像庫中選擇一個圖像作爲背景,然後選擇他們的徽標,他們也可以從他們的(照片)庫中選擇...如何覆蓋xcode中的圖像的圖像?
目前我還沒有找到可以幫助我的教程,主要是因爲用戶必須能夠設置自己的圖像而不是默認圖像。 此外,你們中的任何一個人也知道我可以擁有多個UIImagePickerControllers,因爲這段代碼同時影響兩個圖像而不是每個選擇器?
我用的/有:
我使用SWIFT
我使用的Xcode 7.0.1
這是 the storyboard i currently use。
我的快捷文件:
class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
@IBOutlet weak var logo: UIImageView!
@IBOutlet weak var bgimg: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func selectbg(sender: AnyObject) {
let bgPicker = UIImagePickerController()
bgPicker.delegate = self
bgPicker.sourceType = .PhotoLibrary
self.presentViewController(bgPicker, animated: true, completion: nil)
}
@IBAction func selectlogo(sender: AnyObject) {
let logoPicker = UIImagePickerController()
logoPicker.delegate = self
logoPicker.sourceType = .PhotoLibrary
self.presentViewController(logoPicker, animated: true, completion: nil)
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) {
logo.image = image
bgimg.image = image
self.dismissViewControllerAnimated(false, completion: nil)
}
@IBAction func addImage(sender: AnyObject) {
let ActionAlert = UIAlertController(title: nil, message: "What image do you want to add/edit?", preferredStyle: .ActionSheet)
let bgimage = UIAlertAction(title: "Background", style: .Default, handler: { (Alert:UIAlertAction!) -> Void in
print("Edit background image")
})
let logo = UIAlertAction(title: "Logo", style: .Default) { (Alert:UIAlertAction!) -> Void in
print("Edit logo")
}
let cancel = UIAlertAction(title: "Cancel", style: .Cancel) { (Alert:UIAlertAction!) -> Void in
print("remove menu")
}
ActionAlert.addAction(bgimage)
ActionAlert.addAction(logo)
ActionAlert.addAction(cancel)
self.presentViewController(ActionAlert, animated: true, completion: nil)
}
}
如果我就不清楚了,我的問題,隨時問更多的信息
美麗。謝謝您的回答! – dinesharjani