Commit 1403d482 authored by David黄金龙's avatar David黄金龙

Merge branch 'develop' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS into develop

* 'develop' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS:
  添加相机授权 取消事件
  按钮逻辑
parents 8a853a33 ab689462
......@@ -17,6 +17,7 @@
import UIKit
import Alamofire
import Photos
class YHImagePickerView: UIView {
var backImage: ((UIImage) -> Void)?
......@@ -164,6 +165,7 @@ class YHImagePickerView: UIView {
}
@objc func takePhoto() {
guard getPhotoLibraryAuthorization() else { return }
if UIImagePickerController.isSourceTypeAvailable(.camera){
//创建图片控制器
let imagePicker = UIImagePickerController()
......@@ -183,6 +185,7 @@ class YHImagePickerView: UIView {
}
@objc func selectPhoto() {
guard getPhotoLibraryAuthorization() else { return }
if UIImagePickerController.isSourceTypeAvailable(.photoLibrary){
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
......@@ -192,6 +195,28 @@ class YHImagePickerView: UIView {
UIViewController.current?.present(imagePicker,animated: true)
}
}
private func getPhotoLibraryAuthorization() -> Bool {
let authorizationStatus = PHPhotoLibrary.authorizationStatus()
switch authorizationStatus {
case .authorized:
print("已经授权")
return true
case .notDetermined:
print("不确定是否授权")
// 请求授权
PHPhotoLibrary.requestAuthorization({ (status) in })
case .denied:
print("拒绝授权")
case .restricted:
print("限制授权")
break
case .limited: break
@unknown default:
break
}
return false
}
}
extension YHImagePickerView: UIGestureRecognizerDelegate {
......@@ -219,7 +244,7 @@ extension YHImagePickerView: UINavigationControllerDelegate, UIImagePickerContro
}
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
picker.dismiss(animated: true, completion: nil)
}
//原生上传
......
......@@ -19,9 +19,9 @@ class YHWorkMessageSelectTableViewCell: UITableViewCell {
var rightButton: UIButton!
var dataSource: Int?{
didSet {
var flag = true
var flag = false
if dataSource == 1 {
flag = false
flag = true
}
buttonState(isLeft: flag)
}
......@@ -158,14 +158,6 @@ class YHWorkMessageSelectTableViewCell: UITableViewCell {
func buttonState(isLeft: Bool) {
if isLeft {
leftButton.isSelected = true
rightButton.isSelected = false
leftButton.layer.borderWidth = 1
leftButton.layer.borderColor = UIColor(hex: 0x2f7ef6).cgColor
leftButton.backgroundColor = UIColor(hex: 0x2f7ef6).withAlphaComponent(0.08)
rightButton.backgroundColor = UIColor.contentBkgColor
rightButton.layer.borderWidth = 0
} else {
rightButton.isSelected = true
leftButton.isSelected = false
rightButton.layer.borderWidth = 1
......@@ -173,6 +165,14 @@ class YHWorkMessageSelectTableViewCell: UITableViewCell {
rightButton.backgroundColor = UIColor(hex: 0x2f7ef6).withAlphaComponent(0.08)
leftButton.backgroundColor = UIColor.contentBkgColor
leftButton.layer.borderWidth = 0
} else {
leftButton.isSelected = true
rightButton.isSelected = false
leftButton.layer.borderWidth = 1
leftButton.layer.borderColor = UIColor(hex: 0x2f7ef6).cgColor
leftButton.backgroundColor = UIColor(hex: 0x2f7ef6).withAlphaComponent(0.08)
rightButton.backgroundColor = UIColor.contentBkgColor
rightButton.layer.borderWidth = 0
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment