Skip to content

Commit

Permalink
Merge pull request #1 from duygubatkan/bug
Browse files Browse the repository at this point in the history
* input nil bug solved
  • Loading branch information
duygubatkan authored Sep 14, 2018
2 parents ea33c72 + d6641fb commit ba9acdc
Show file tree
Hide file tree
Showing 7 changed files with 1,025 additions and 848 deletions.
47 changes: 27 additions & 20 deletions Source/LBXPermissions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ import AVFoundation
import Photos
import AssetsLibrary



class LBXPermissions: NSObject {

// MARK: - ---获取相册权限
static func authorizePhotoWith(comletion:@escaping (Bool) -> Void) {
//MARK: ----获取相册权限
static func authorizePhotoWith(comletion:@escaping (Bool)->Void )
{
let granted = PHPhotoLibrary.authorizationStatus()
switch granted {
case PHAuthorizationStatus.authorized:
comletion(true)
case PHAuthorizationStatus.denied, PHAuthorizationStatus.restricted:
case PHAuthorizationStatus.denied,PHAuthorizationStatus.restricted:
comletion(false)
case PHAuthorizationStatus.notDetermined:
PHPhotoLibrary.requestAuthorization({ (status) in
Expand All @@ -29,41 +32,45 @@ class LBXPermissions: NSObject {
})
}
}

// MARK: - --相机权限
static func authorizeCameraWith(comletion:@escaping (Bool) -> Void ) {
let granted = AVCaptureDevice.authorizationStatus(for: AVMediaType.video)


//MARK: ---相机权限
static func authorizeCameraWith(comletion:@escaping (Bool)->Void )
{
let granted = AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo);

switch granted {
case .authorized:
comletion(true)
break
break;
case .denied:
comletion(false)
break
break;
case .restricted:
comletion(false)
break
break;
case .notDetermined:
AVCaptureDevice.requestAccess(for: AVMediaType.video, completionHandler: { (granted: Bool) in
AVCaptureDevice.requestAccess(forMediaType: AVMediaTypeVideo, completionHandler: { (granted:Bool) in
DispatchQueue.main.async {
comletion(granted)
}
})
}
}

// MARK: 跳转到APP系统设置权限界面
static func jumpToSystemPrivacySetting() {
let appSetting = URL(string: UIApplicationOpenSettingsURLString)

if appSetting != nil {

//MARK:跳转到APP系统设置权限界面
static func jumpToSystemPrivacySetting()
{
let appSetting = URL(string:UIApplicationOpenSettingsURLString)

if appSetting != nil
{
if #available(iOS 10, *) {
UIApplication.shared.open(appSetting!, options: [:], completionHandler: nil)
} else {
}
else{
UIApplication.shared.openURL(appSetting!)
}
}
}

}
102 changes: 57 additions & 45 deletions Source/LBXScanLineAnimation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,66 +12,78 @@ class LBXScanLineAnimation: UIImageView {

var isAnimationing = false
var animationRect: CGRect = CGRect.zero

func startAnimatingWithRect(animationRect: CGRect, parentView: UIView, image: UIImage?) {

func startAnimatingWithRect(animationRect: CGRect, parentView: UIView, image: UIImage?)
{
self.image = image
self.animationRect = animationRect
parentView.addSubview(self)

self.isHidden = false

isAnimationing = true

if image != nil {

self.isHidden = false;

isAnimationing = true;

if image != nil
{
stepAnimation()
}

}

@objc func stepAnimation() {

@objc func stepAnimation()
{
if (!isAnimationing) {
return
return;
}

var frame: CGRect = animationRect

let hImg = self.image!.size.height * animationRect.size.width / self.image!.size.width

frame.origin.y -= hImg
frame.size.height = hImg
self.frame = frame
self.alpha = 0.0

var frame:CGRect = animationRect;
let hImg = self.image!.size.height * animationRect.size.width / self.image!.size.width;
frame.origin.y -= hImg;
frame.size.height = hImg;
self.frame = frame;
self.alpha = 0.0;
UIView.animate(withDuration: 1.4, animations: { () -> Void in

self.alpha = 1.0

var frame = self.animationRect
let hImg = self.image!.size.height * self.animationRect.size.width / self.image!.size.width

frame.origin.y += (frame.size.height - hImg)
frame.size.height = hImg

self.frame = frame

}, completion: { (_: Bool) -> Void in

self.perform(#selector(LBXScanLineAnimation.stepAnimation), with: nil, afterDelay: 0.3)
self.alpha = 1.0;
var frame = self.animationRect;
let hImg = self.image!.size.height * self.animationRect.size.width / self.image!.size.width;
frame.origin.y += (frame.size.height - hImg);
frame.size.height = hImg;
self.frame = frame;
}, completion:{ (value: Bool) -> Void in
self.perform(#selector(LBXScanLineAnimation.stepAnimation), with: nil, afterDelay: 0.3)
})

}

func stopStepAnimating() {
self.isHidden = true
isAnimationing = false

func stopStepAnimating()
{
self.isHidden = true;
isAnimationing = false;
}

static public func instance() -> LBXScanLineAnimation {

static public func instance()->LBXScanLineAnimation
{
return LBXScanLineAnimation()
}

deinit {

deinit
{
// print("LBXScanLineAnimation deinit")
stopStepAnimating()
}

}





94 changes: 51 additions & 43 deletions Source/LBXScanNetAnimation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,62 +11,70 @@ import UIKit
class LBXScanNetAnimation: UIImageView {

var isAnimationing = false
var animationRect: CGRect = CGRect.zero
var animationRect:CGRect = CGRect.zero

static public func instance() -> LBXScanNetAnimation {
static public func instance()->LBXScanNetAnimation
{
return LBXScanNetAnimation()
}

func startAnimatingWithRect(animationRect: CGRect, parentView: UIView, image: UIImage?) {

func startAnimatingWithRect(animationRect:CGRect, parentView:UIView, image:UIImage?)
{
self.image = image
self.animationRect = animationRect
parentView.addSubview(self)

self.isHidden = false

isAnimationing = true

if (image != nil) {
stepAnimation()

self.isHidden = false;

isAnimationing = true;

if (image != nil)
{
stepAnimation()
}

}

@objc func stepAnimation() {

@objc func stepAnimation()
{
if (!isAnimationing) {
return
return;
}
var frame = animationRect
let hImg = self.image!.size.height * animationRect.size.width / self.image!.size.width

frame.origin.y -= hImg
frame.size.height = hImg
self.frame = frame

self.alpha = 0.0


var frame = animationRect;


let hImg = self.image!.size.height * animationRect.size.width / self.image!.size.width;

frame.origin.y -= hImg;
frame.size.height = hImg;
self.frame = frame;

self.alpha = 0.0;

UIView.animate(withDuration: 1.2, animations: { () -> Void in

self.alpha = 1.0

var frame = self.animationRect
let hImg = self.image!.size.height * self.animationRect.size.width / self.image!.size.width

frame.origin.y += (frame.size.height - hImg)
frame.size.height = hImg

self.frame = frame

}, completion: { (_: Bool) -> Void in

self.perform(#selector(LBXScanNetAnimation.stepAnimation), with: nil, afterDelay: 0.3)

self.alpha = 1.0;
var frame = self.animationRect;
let hImg = self.image!.size.height * self.animationRect.size.width / self.image!.size.width;
frame.origin.y += (frame.size.height - hImg);
frame.size.height = hImg;
self.frame = frame;
}, completion:{ (value: Bool) -> Void in
self.perform(#selector(LBXScanNetAnimation.stepAnimation), with: nil, afterDelay: 0.3)
})

}

func stopStepAnimating() {
self.isHidden = true
isAnimationing = false

func stopStepAnimating()
{
self.isHidden = true;
isAnimationing = false;
}

}
Loading

0 comments on commit ba9acdc

Please sign in to comment.