Tag v0.0.1
- iOS 7.0+
- Xcode 6.3
let storyboard:UIStoryboard = UIStoryboard(name: "Mockingbird", bundle: NSBundle.mainBundle())
let navC:UINavigationController = storyboard.instantiateViewControllerWithIdentifier("MockingbirdNavigationID") as! UINavigationController
let mockingbird:MockingbirdScanCodeManager = navC.topViewController as! MockingbirdScanCodeManager
mockingbird.globalTitle = "扫描条码"
mockingbird.globalColor = MOKTeal
self.presentViewController(navC, animated: true, completion: nil)
- globalColor:UIColor? 设置全局的颜色
- globalTitle:String? 设置导航标题
- previewLineColor:UIColor? 设置线动画的颜色
NSNotificationCenter.defaultCenter().addObserver(self, selector: "mockingbird:", name:MOKNotifiScanResult, object: nil)
scan code result | 通过通知来获取扫描的结果
scan code result | 或者通过回调函数
mockingbird.mockingbirdResult = {(value:String?)->Void in
println(value)
println("回调函数")
if let _value = value{
self.scancode.text = _value
}
}
how learning used AVFoundation to create scan code | 利用AVFoundation实现扫描条码
create bridging header file and set module Yes,then you import product name -Swift.h file
UIStoryboard *stor = [UIStoryboard storyboardWithName:@"Mockingbird" bundle:[NSBundle mainBundle]];
UINavigationController *navc = [stor instantiateViewControllerWithIdentifier:@"MockingbirdNavigationID"];
MockingbirdScanCodeManager *mocking = (MockingbirdScanCodeManager *)navc.topViewController;
mocking.mockingbirdResult = ^(NSString * __nonnull value){
self.showScanCodeInfo.text = value;
};
[self presentViewController:navc animated:YES completion:nil];
This code is distributed under the terms and conditions of the MIT license.