Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
zhangyongji
/
MRFramework
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
458625a9
authored
Nov 27, 2019
by
Sarkizz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
相机添加前后置摄像头类型
parent
38b8ec29
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
4 deletions
+22
-4
MRFramework/MRFramework/UIControls/PhotoPicker/SAPhotoPicker.swift
+22
-4
No files found.
MRFramework/MRFramework/UIControls/PhotoPicker/SAPhotoPicker.swift
View file @
458625a9
...
...
@@ -9,12 +9,26 @@
import
Foundation
import
UIKit
public
enum
SACameraDeviceType
{
case
rear
case
front
var
device
:
UIImagePickerController
.
CameraDevice
{
switch
self
{
case
.
rear
:
return
.
rear
case
.
front
:
return
.
front
}
}
}
/// Picker类型
public
enum
SAPhotoPickerType
{
/// 先显示一个actionSheet,选择类型。count是自定义相册的选择图片数量
case
all
(
count
:
Int
)
/// 相机
case
camera
case
camera
(
_
type
:
SACameraDeviceType
)
/// 系统相册
case
photo
/// 系统相册
...
...
@@ -84,8 +98,8 @@ public class SAPhotoPicker: NSObject {
UIApplication
.
shared
.
keyWindow
?
.
rootViewController
?
.
present
(
alert
,
animated
:
true
,
completion
:
nil
)
case
.
photo
:
self
.
showImagePicker
(
.
photoLibrary
)
case
.
camera
:
self
.
showImagePicker
(
.
camera
)
case
.
camera
(
let
type
)
:
self
.
showImagePicker
(
.
camera
,
device
:
type
.
device
)
case
.
savedPhotosAlbum
:
self
.
showImagePicker
(
.
savedPhotosAlbum
)
case
.
custom
(
let
count
):
...
...
@@ -95,12 +109,16 @@ public class SAPhotoPicker: NSObject {
}
extension
SAPhotoPicker
{
private
func
showImagePicker
(
_
type
:
UIImagePickerController
.
SourceType
)
{
private
func
showImagePicker
(
_
type
:
UIImagePickerController
.
SourceType
,
device
:
UIImagePickerController
.
CameraDevice
?
=
nil
)
{
let
vc
=
UIImagePickerController
()
vc
.
sourceType
=
type
vc
.
delegate
=
self
vc
.
title
=
navTitle
(
with
:
type
)
vc
.
allowsEditing
=
editable
if
let
device
=
device
{
vc
.
cameraDevice
=
device
}
UIApplication
.
shared
.
keyWindow
?
.
rootViewController
?
.
present
(
vc
,
animated
:
true
,
completion
:
nil
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment