Skip to content

Commit

Permalink
添加版本0.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
施峰磊 committed Aug 25, 2021
1 parent 009eec4 commit 3db2405
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 42 deletions.
Binary file modified .DS_Store
Binary file not shown.
78 changes: 38 additions & 40 deletions Classes/SRAlbum.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ var is_rectangle_detection = false;//开启矩形检测

public class SRAlbumWrapper:NSObject{

@available(iOS 10, *)
@objc public class func openAlbum(tager:UIViewController, assetType:SRAssetType = .None, maxCount:Int = 1, isEidt:Bool = false, isSort:Bool = false, maxSize:Int = 2*1024*1024, completeHandle:((Array<Any>)->Void)?)->Void{
if tager.isCanOpenAlbums() {

Expand Down Expand Up @@ -118,26 +119,24 @@ public class SRAlbumWrapper:NSObject{
tager.present(alertController, animated: true, completion: nil)
}
}

@objc public func openCamera(tager:UIViewController,cameraType:SRCameraType = .Photo, isRectangleDetection:Bool = false, isEidt:Bool = false, maxSize:Int = 2*1024*1024, completeHandle:((UIImage?,URL?)->Void)?)->Void{
if #available(iOS 12, *) {
tager.checkCamera(cameraType: cameraType) { authorization in
camera_type = cameraType
is_eidt = isEidt
max_size = maxSize
is_rectangle_detection = isRectangleDetection
SRAlbumData.sharedInstance.completeVedioHandle = completeHandle
SRAlbumData.sharedInstance.isZip = maxSize>0;
let vc:SRCameraViewController = SRCameraViewController.init(nibName: "SRCameraViewController", bundle:bundle)
let nv:SRNavigationController = SRNavigationController.init(rootViewController: vc)
nv.navigationBar.barTintColor = UIColor.init(red: 44.0/255.0, green: 44.0/255.0, blue: 44.0/255.0, alpha: 1.0)
nv.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
nv.navigationBar.tintColor = UIColor.white
nv.navigationBar.barStyle = .black
nv.modalPresentationStyle = .fullScreen
nv.isNavigationBarHidden = true
tager.present(nv, animated: true, completion: nil)
}
@available(iOS 10, *)
@objc public class func openCamera(tager:UIViewController,cameraType:SRCameraType = .Photo, isRectangleDetection:Bool = false, isEidt:Bool = false, maxSize:Int = 2*1024*1024, completeHandle:((UIImage?,URL?)->Void)?)->Void{
tager.checkCamera(cameraType: cameraType) { authorization in
camera_type = cameraType
is_eidt = isEidt
max_size = maxSize
is_rectangle_detection = isRectangleDetection
SRAlbumData.sharedInstance.completeVedioHandle = completeHandle
SRAlbumData.sharedInstance.isZip = maxSize>0;
let vc:SRCameraViewController = SRCameraViewController.init(nibName: "SRCameraViewController", bundle:bundle)
let nv:SRNavigationController = SRNavigationController.init(rootViewController: vc)
nv.navigationBar.barTintColor = UIColor.init(red: 44.0/255.0, green: 44.0/255.0, blue: 44.0/255.0, alpha: 1.0)
nv.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
nv.navigationBar.tintColor = UIColor.white
nv.navigationBar.barStyle = .black
nv.modalPresentationStyle = .fullScreen
nv.isNavigationBarHidden = true
tager.present(nv, animated: true, completion: nil)
}
}
}
Expand All @@ -152,6 +151,7 @@ extension UIViewController{
/// - isSort: 是否要排序输出图片;默认为false
/// - maxSize: 限制图片的M数,;默认为2*1024*1024,也就是2M
/// - completeHandle: 回调结果
@available(iOS 10, *)
@objc public func openAlbum(assetType:SRAssetType = .None, maxCount:Int = 1, isEidt:Bool = false, isSort:Bool = false, maxSize:Int = 2*1024*1024, completeHandle:((Array<Any>)->Void)?)->Void{
if self.isCanOpenAlbums() {
PHPhotoLibrary.requestAuthorization { (status) in
Expand Down Expand Up @@ -193,7 +193,6 @@ extension UIViewController{
self.present(alertController, animated: true, completion: nil)
}
}


/// 打开相机
/// - Parameters:
Expand All @@ -203,25 +202,24 @@ extension UIViewController{
/// - maxSize: 限制图片的M数,;默认为2*1024*1024,也就是2M
/// - completeHandle: 回调结果
/// - Returns: 空
public func openCamera(cameraType:SRCameraType = .Photo, isRectangleDetection:Bool = false, isEidt:Bool = false, maxSize:Int = 2*1024*1024, completeHandle:((UIImage?,URL?)->Void)?)->Void{
if #available(iOS 12, *) {
self.checkCamera(cameraType: cameraType) {[weak self] authorization in
camera_type = cameraType
is_eidt = isEidt
max_size = maxSize
is_rectangle_detection = isRectangleDetection
SRAlbumData.sharedInstance.completeVedioHandle = completeHandle
SRAlbumData.sharedInstance.isZip = maxSize>0;
let vc:SRCameraViewController = SRCameraViewController.init(nibName: "SRCameraViewController", bundle:bundle)
let nv:SRNavigationController = SRNavigationController.init(rootViewController: vc)
nv.navigationBar.barTintColor = UIColor.init(red: 44.0/255.0, green: 44.0/255.0, blue: 44.0/255.0, alpha: 1.0)
nv.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
nv.navigationBar.tintColor = UIColor.white
nv.navigationBar.barStyle = .black
nv.modalPresentationStyle = .fullScreen
nv.isNavigationBarHidden = true
self?.present(nv, animated: true, completion: nil)
}
@available(iOS 10, *)
@objc public func openCamera(cameraType:SRCameraType = .Photo, isRectangleDetection:Bool = false, isEidt:Bool = false, maxSize:Int = 2*1024*1024, completeHandle:((UIImage?,URL?)->Void)?)->Void{
self.checkCamera(cameraType: cameraType) {[weak self] authorization in
camera_type = cameraType
is_eidt = isEidt
max_size = maxSize
is_rectangle_detection = isRectangleDetection
SRAlbumData.sharedInstance.completeVedioHandle = completeHandle
SRAlbumData.sharedInstance.isZip = maxSize>0;
let vc:SRCameraViewController = SRCameraViewController.init(nibName: "SRCameraViewController", bundle:bundle)
let nv:SRNavigationController = SRNavigationController.init(rootViewController: vc)
nv.navigationBar.barTintColor = UIColor.init(red: 44.0/255.0, green: 44.0/255.0, blue: 44.0/255.0, alpha: 1.0)
nv.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
nv.navigationBar.tintColor = UIColor.white
nv.navigationBar.barStyle = .black
nv.modalPresentationStyle = .fullScreen
nv.isNavigationBarHidden = true
self?.present(nv, animated: true, completion: nil)
}
}

Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# swift使用方法
导入模块:import SRAlbum

相册使用:
调用方法1:
SRAlbumWrapper.openAlbum(tager: self, maxCount: 5, isEidt: true, isSort: true) { (assets) in
print("assets")
Expand All @@ -23,10 +24,21 @@
print("assets")
}

相机使用:
调用方法1:
SRAlbumWrapper.openCamera(tager: self, cameraType: .Photo, isRectangleDetection: false, isEidt: true, maxSize: 2*1024*1024) { (img:UIImage?, url:URL?) in
}
调用方法2:
self.openCamera(cameraType: .Photo, isRectangleDetection: true, isEidt: true) { [weak self](img:UIImage?, url:URL?) in

}


# Objective-C使用方法
导入模块:#import <SRAlbum-Swift.h>

相册使用:
调用方法1:
[SRAlbumWrapper openAlbumWithTager:(UIViewController * _Nonnull) assetType:(enum SRAssetType) maxCount:(NSInteger) isEidt:(BOOL) isSort:(BOOL) maxSize:(NSInteger) completeHandle:^(NSArray * list) {
Expand All @@ -36,9 +48,21 @@
NSLog(@"");
}];

相机使用:
调用方法1:
[SRAlbumWrapper openCameraWithTager:self cameraType:SRCameraTypePhoto isRectangleDetection:true isEidt:true maxSize:2*1024*1024 completeHandle:^(UIImage * img, NSURL * url) {
}];
调用方法2:
[self openCameraWithCameraType:SRCameraTypePhoto isRectangleDetection:true isEidt:true maxSize:2*1024*1024 completeHandle:^(UIImage * img, NSURL * url) {
}];


assetType: .None:任意列席,.Photo:图片类型,.Video:视频类型;默认为.None
maxCount: 取图片或者视频的数量;默认为1
isEidt: 是否要编辑;默认为false
isSort: 是否要排序输出图片;默认为false
maxSize: 限制图片的M数,;默认为2*1024*1024,也就是2M
cameraType: .Photo 拍照,.Video 录像
isRectangleDetection: 是否矩形检测
4 changes: 2 additions & 2 deletions SRAlbum.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |spec|
#

spec.name = "SRAlbum"
spec.version = "0.0.3"
spec.version = "0.0.4"
spec.summary = "相册和相机模块"
spec.swift_version = "5.0"

Expand Down Expand Up @@ -69,7 +69,7 @@ Pod::Spec.new do |spec|
# spec.platform = :ios, "5.0"

# When using multiple platforms
spec.ios.deployment_target = "9.0"
spec.ios.deployment_target = "10.0"
# spec.osx.deployment_target = "10.7"
# spec.watchos.deployment_target = "2.0"
# spec.tvos.deployment_target = "9.0"
Expand Down
4 changes: 4 additions & 0 deletions SRAlbum/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class ViewController: UIViewController {

}
}

SRAlbumWrapper.openCamera(tager: self, cameraType: .Photo, isRectangleDetection: false, isEidt: true, maxSize: 2*1024*1024) { (img:UIImage?, url:URL?) in

}
}

}
Expand Down

0 comments on commit 3db2405

Please sign in to comment.