Skip to content

Commit

Permalink
Merge pull request MxABC#13 from CNKCQ/Swift3.0
Browse files Browse the repository at this point in the history
Swift3.0
  • Loading branch information
MxABC committed Sep 30, 2016
2 parents 1f47f20 + fa41b99 commit 661fdd9
Show file tree
Hide file tree
Showing 17 changed files with 797 additions and 390 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@

# ios 二维码、条形码 swift 版本
# iOS 二维码、条形码 Swift 版本 Swift 2.2, Swift 2.3, Swift 3.0


###objective-c Version <img src="https://github.com/MxABC/LBXScan/blob/master/DemoTests/objectiveCIcon.jpg" height="55" width="40">
对应的Objective-c版本: **[LBXScan](https://github.com/MxABC/LBXScan)**

### xcode
测试程序 xcode版本号:xcode7.1
测试程序 xcode版本号:Xcode7.1 、Xcode 8


## 介绍
**swift封装系统自带扫码及识别图片功能**
Expand Down Expand Up @@ -42,6 +43,15 @@ platform :ios, '8.0'
use_frameworks!
pod 'swiftScan'
```
Swift 2.3
```ruby
pod 'swiftScan', :git => 'https://github.com/CNKCQ/swiftScan.git'
```

Swift 3.0
```ruby
pod 'swiftScan', :git => 'https://github.com/CNKCQ/swiftScan.git', :branch => 'Swift3.0'
```

### 手动安装
下载后将Source文件夹copy到工程即可
Expand Down
17 changes: 7 additions & 10 deletions Source/LBXPermissions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class LBXPermissions: NSObject {
static func isGetCameraPermission()->Bool
{

let authStaus = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo)
let authStaus = AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo)

if authStaus != AVAuthorizationStatus.Denied
if authStaus != AVAuthorizationStatus.denied
{
return true
}
Expand All @@ -35,21 +35,18 @@ class LBXPermissions: NSObject {
static func isGetPhotoPermission()->Bool
{
var bResult = false
if Float(UIDevice.currentDevice().systemVersion) < 8.0
{
if( ALAssetsLibrary.authorizationStatus() != ALAuthorizationStatus.Denied )
if #available(iOS 8.0, *) {
if ( PHPhotoLibrary.authorizationStatus() != PHAuthorizationStatus.denied )
{
bResult = true
}
}
else
{
if ( PHPhotoLibrary.authorizationStatus() != PHAuthorizationStatus.Denied )
} else {
if( ALAssetsLibrary.authorizationStatus() != ALAuthorizationStatus.denied )
{
bResult = true
}
}

return bResult
}

Expand Down
10 changes: 5 additions & 5 deletions Source/LBXScanLineAnimation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import UIKit
class LBXScanLineAnimation: UIImageView {

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

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

self.hidden = false;
self.isHidden = false;

isAnimationing = true;

Expand All @@ -45,7 +45,7 @@ class LBXScanLineAnimation: UIImageView {
self.frame = frame;
self.alpha = 0.0;

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

self.alpha = 1.0;

Expand All @@ -59,14 +59,14 @@ class LBXScanLineAnimation: UIImageView {

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

self.performSelector(#selector(LBXScanLineAnimation.stepAnimation), withObject: nil, afterDelay: 0.3)
self.perform(#selector(LBXScanLineAnimation.stepAnimation), with: nil, afterDelay: 0.3)
})

}

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

Expand Down
13 changes: 6 additions & 7 deletions Source/LBXScanNetAnimation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import UIKit
class LBXScanNetAnimation: UIImageView {

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



static public func instance()->LBXScanNetAnimation
Expand All @@ -25,7 +26,7 @@ class LBXScanNetAnimation: UIImageView {
self.animationRect = animationRect
parentView.addSubview(self)

self.hidden = false;
self.isHidden = false;

isAnimationing = true;

Expand Down Expand Up @@ -55,7 +56,7 @@ class LBXScanNetAnimation: UIImageView {

self.alpha = 0.0;

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

self.alpha = 1.0;

Expand All @@ -69,18 +70,16 @@ class LBXScanNetAnimation: UIImageView {

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

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

})

}

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



}
Loading

0 comments on commit 661fdd9

Please sign in to comment.