擷取圖片(swift)

來源:互聯網
上載者:User

標籤:swift

擷取相機(swift)by 伍雪穎


@IBActionfunc takePhoto(sender:AnyObject) {
  view.endEditing(true)
  moveViewDown()
 
  let imagePickerActionSheet =UIAlertController(title:"Snap/Upload Photo",
    message: nil, preferredStyle: .ActionSheet)
 
  ifUIImagePickerController.isSourceTypeAvailable(.Camera) {
    let cameraButton =UIAlertAction(title:"Take Photo",
      style: .Default) { (alert) ->Voidin
        let imagePicker =UIImagePickerController()
        imagePicker.delegate =self
        imagePicker.sourceType = .Camera
        self.presentViewController(imagePicker,
          animated: true,
          completion: nil)
    }
    imagePickerActionSheet.addAction(cameraButton)
  }
 
  let libraryButton =UIAlertAction(title:"Choose Existing",
    style: .Default) { (alert) ->Voidin
      let imagePicker =UIImagePickerController()
      imagePicker.delegate =self
      imagePicker.sourceType = .PhotoLibrary
      self.presentViewController(imagePicker,
        animated: true,
        completion: nil)
  }
  imagePickerActionSheet.addAction(libraryButton)
 
  let cancelButton =UIAlertAction(title:"Cancel",
    style: .Cancel) { (alert) ->Voidin
  }
  imagePickerActionSheet.addAction(cancelButton)
 
  presentViewController(imagePickerActionSheet, animated:true,
    completion: nil)}

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

擷取圖片(swift)

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.