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
0d0fa55d
authored
Sep 02, 2019
by
Sarkizz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
相册添加是否可编辑选项设置
parent
c5460107
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
MRFramework/MRFramework/UIControls/PhotoPicker/SAPhotoPicker.swift
+17
-2
No files found.
MRFramework/MRFramework/UIControls/PhotoPicker/SAPhotoPicker.swift
View file @
0d0fa55d
...
...
@@ -32,6 +32,8 @@ extension SAPhotoPicker.ConfigKey {
public
static
let
cameraTitle
=
SAPhotoPicker
.
ConfigKey
(
rawValue
:
"SAPhotoPicker.cameraTitle"
)
public
static
let
libraryTitle
=
SAPhotoPicker
.
ConfigKey
(
rawValue
:
"SAPhotoPicker.libraryTitle"
)
public
static
let
albumTitle
=
SAPhotoPicker
.
ConfigKey
(
rawValue
:
"SAPhotoPicker.albumTitle"
)
public
static
let
editable
=
SAPhotoPicker
.
ConfigKey
(
rawValue
:
"SAPhotoPicker.editable"
)
}
public
class
SAPhotoPicker
:
NSObject
{
...
...
@@ -40,7 +42,8 @@ public class SAPhotoPicker: NSObject {
var
config
:
[
SAPhotoPicker
.
ConfigKey
:
Any
]
=
[
.
cameraTitle
:
"拍照"
,
.
libraryTitle
:
"相册"
,
.
albumTitle
:
"相册"
.
albumTitle
:
"相册"
,
.
editable
:
false
]
private
var
complateBlock
:
SAPhotoPickerComplateBlock
?
...
...
@@ -81,6 +84,7 @@ extension SAPhotoPicker {
vc
.
sourceType
=
type
vc
.
delegate
=
self
vc
.
title
=
navTitle
(
with
:
type
)
vc
.
allowsEditing
=
editable
UIApplication
.
shared
.
keyWindow
?
.
rootViewController
?
.
present
(
vc
,
animated
:
true
,
completion
:
nil
)
}
...
...
@@ -96,11 +100,22 @@ extension SAPhotoPicker {
return
nil
}
}
private
var
editable
:
Bool
{
return
config
[
.
editable
]
as?
Bool
??
false
}
}
extension
SAPhotoPicker
:
UINavigationControllerDelegate
,
UIImagePickerControllerDelegate
{
public
func
imagePickerController
(
_
picker
:
UIImagePickerController
,
didFinishPickingMediaWithInfo
info
:
[
UIImagePickerController
.
InfoKey
:
Any
])
{
if
let
image
=
info
[
.
originalImage
]
as?
UIImage
{
var
image
:
UIImage
?
{
if
editable
{
return
info
[
.
editedImage
]
as?
UIImage
}
return
info
[
.
originalImage
]
as?
UIImage
}
if
let
image
=
image
{
complateBlock
?(
image
,
info
[
.
referenceURL
]
as?
URL
,
nil
)
}
else
{
complateBlock
?(
nil
,
nil
,
error
(
code
:
-
1
,
msg
:
"获取图片失败"
))
...
...
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