Compare commits

..

21 Commits

Author SHA1 Message Date
Ricardo Torrão 22f3e5320e more Swift 3.0 changes 2016-09-16 15:05:26 +01:00
Ricardo Torrão 8f31fba846 Merge pull request #61 from dimohamdy/swift-3.0
update for Swift 3.0
2016-09-16 12:27:46 +01:00
dimohamdy 206bce0e94 update demo to support swift 3 2016-08-19 04:08:26 +03:00
dimohamdy 0267cc2664 support swift 3 2016-08-19 04:04:13 +03:00
Ricardo Torrão 389ec550b3 2.2.4 2016-07-06 14:35:54 +01:00
Ricardo Torrão c8605d523a add error checking 2016-07-06 14:34:01 +01:00
Ricardo Torrão 6ce822261d Update README.md 2016-07-06 14:07:51 +01:00
Ricardo Torrão c0c55be070 checks if an output can be added to the session (issue #49) 2016-07-06 12:58:28 +01:00
Ricardo Torrão b23f2ccbc4 fixes completition typos and suggests renamed functions 2016-07-06 11:55:53 +01:00
Ricardo Torrão 004876d34e Update README.md 2016-07-06 11:08:30 +01:00
Ricardo Torrão dd34c6468e Merge pull request #47 from SongJiaqiang/jq.fixbug
Use a most effective way to retrieve real interface orientation.
2016-07-06 11:05:43 +01:00
Joel Reis 33a0e2b1e4 2.2.3 2016-05-12 17:05:49 +01:00
Joel Reis 4639a1b661 fix zoom in StillImage Mode 2016-05-12 17:02:55 +01:00
Jiaqiang e598b71173 Use a most effective way to retrieve real interface orientation.
UIDevice.currentDevice().orientation returns the orientation of device.
UIApplication.sharedApplication().statusBarOrientation returns the
orientation of UI interface.
For example.
1. check out Portrait only in info.plist.
2. Setup shouldRespondToOrientationChanges=false.
3. Launch app with LandscapeLeft.
Intent: orientation is .Portrait
Actually: orientation is .LandscapeLeft
2016-04-19 17:59:55 +08:00
Ricardo Torrão a12d5e28e9 Update README.md 2016-04-04 22:24:13 +01:00
Daniel Pereira 68e289a755 minor changes to swift 2.2 2016-03-30 15:28:36 +01:00
Daniel Pereira c875a0c03d refactor to more idiomatic swift 2016-03-30 15:26:03 +01:00
Daniel Pereira cf0e3759b4 changed weak self reference to unowned on cameraPictureWithCompletion and cameraPictureDataWithCompletion 2016-03-30 14:20:08 +01:00
Daniel Pereira bfb31dd14b Merge pull request #41 from SongJiaqiang/fork.capturePictureCallback
Add a capture picture callback to pass on image data
2016-03-30 12:15:57 +01:00
jiaqiang c0a95613f1 Add a capture picture callback to pass on image data
Sometimes, user want to store the picture by the other ways, such as a
new album, sand disk and so on. Or cutting, compounding, adding filter.
2016-03-28 23:14:05 +08:00
Ricardo Torrão 935e352460 v2.2.2 2016-03-07 19:02:57 +00:00
10 changed files with 537 additions and 418 deletions

View File

@ -2,8 +2,29 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [2.2.2](https://github.com/imaginary-cloud/CameraManager/tree/2.2.2) - 2016-03-07
## [3.0.0](https://github.com/imaginary-cloud/CameraManager/tree/3.0.0) - 2016-09-16
### Changed
- Syntax update for Swift 3.0.
## [2.2.4](https://github.com/imaginary-cloud/CameraManager/tree/2.2.4) - 2016-07-06
### Added
- Add error checking.
### Changed
- Fixes completion typos and suggests renamed functions.
## [2.2.3](https://github.com/imaginary-cloud/CameraManager/tree/2.2.3) - 2016-05-12
### Changed
- Fixed zoom in StillImage Mode.
- Minor refactoring
## [2.2.2](https://github.com/imaginary-cloud/CameraManager/tree/2.2.2) - 2016-03-07
### Added
- `CHANGELOG.md` file.

View File

@ -1,12 +1,12 @@
Pod::Spec.new do |s|
s.name = "CameraManager"
s.version = "2.2.1"
s.version = "3.0.0"
s.summary = "This is a simple Swift class to provide all the configurations you need to create custom camera view in your app. Just drag, drop and use."
s.requires_arc = true
s.homepage = "https://github.com/imaginary-cloud/CameraManager"
s.license = 'MIT'
s.author = { "torrao" => "rtorrao@imaginarycloud.com" }
s.source = { :git => "https://github.com/imaginary-cloud/CameraManager.git", :tag => "2.2.1" }
s.source = { :git => "https://github.com/imaginary-cloud/CameraManager.git", :tag => "3.0.0" }
s.social_media_url = 'http://www.imaginarycloud.com/'
s.platform = :ios, '8.0'
s.source_files = 'camera/CameraManager.swift'

View File

@ -14,12 +14,20 @@ The easiest way to install the CameraManager is with: [CocoaPods](http://cocoapo
### Podfile
If you want Swift 3.0 syntax use:
```ruby
use_frameworks!
pod 'CameraManager', '~> 3.0'
```
If you want Swift 2.0 syntax use:
```ruby
use_frameworks!
pod 'CameraManager', '~> 2.2
pod 'CameraManager', '~> 2.2'
```
If you want Swift 1.2 syntax use:
@ -52,6 +60,12 @@ let package = Package(
Add the following line to your Cartfile:
If you want Swift 3.0 syntax use:
```
github "imaginary-cloud/CameraManager" >= 3.0
```
If you want Swift 2.0 syntax use:
```
@ -67,7 +81,7 @@ github "imaginary-cloud/CameraManager" >= 1.0
And run `carthage update` to build the dynamic framework.
## How to use
To use it you just add the preview layer to your desired view, you'll get back the state of the camera if it's unavailable, ready or the user denied assess to it. Have in mind that in order to retain the AVCaptureSession you will need to retain cameraManager instance somewhere, ex. as an instance constant.
To use it you just add the preview layer to your desired view, you'll get back the state of the camera if it's unavailable, ready or the user denied access to it. Have in mind that in order to retain the AVCaptureSession you will need to retain cameraManager instance somewhere, ex. as an instance constant.
```swift
let cameraManager = CameraManager()
cameraManager.addPreviewLayerToView(self.cameraView)
@ -141,7 +155,7 @@ cameraManager.showErrorBlock = { (erTitle: String, erMessage: String) -> Void in
To shoot image all you need to do is call:
```swift
cameraManager.capturePictureWithCompletition({ (image, error) -> Void in
cameraManager.capturePictureWithCompletion({ (image, error) -> Void in
self.myImage = image
})
```
@ -149,7 +163,7 @@ cameraManager.capturePictureWithCompletition({ (image, error) -> Void in
To record video you do:
```swift
cameraManager.startRecordingVideo()
cameraManager.stopRecordingVideo({ (videoURL, error) -> Void in
cameraManager.stopVideoRecording({ (videoURL, error) -> Void in
NSFileManager.defaultManager().copyItemAtURL(videoURL, toURL: self.myVideoURL, error: &error)
})
```

View File

@ -201,14 +201,17 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0700;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = imaginaryCloud;
TargetAttributes = {
454C1F4019E82E2500C81915 = {
CreatedOnToolsVersion = 6.0.1;
DevelopmentTeam = QM7HJTY23M;
LastSwiftMigration = 0800;
};
D71DE8801AD677A7001E62F1 = {
CreatedOnToolsVersion = 6.3;
LastSwiftMigration = 0800;
};
};
};
@ -313,8 +316,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "";
@ -324,6 +329,7 @@
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
@ -358,8 +364,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@ -367,6 +375,7 @@
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
@ -376,6 +385,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
@ -385,11 +395,13 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = camera/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = cameraDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
@ -397,17 +409,20 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = camera/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = cameraDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
D71DE89B1AD677A8001E62F1 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
@ -426,6 +441,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.imaginarycloud.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
@ -434,6 +450,7 @@
D71DE89C1AD677A8001E62F1 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
@ -449,6 +466,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.imaginarycloud.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@ -23,21 +23,21 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
@ -55,10 +55,10 @@
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference

View File

@ -14,30 +14,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(application: UIApplication) {
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(application: UIApplication) {
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(application: UIApplication) {
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(application: UIApplication) {
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(application: UIApplication) {
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@ class ImageViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBar.hidden = false
self.navigationController?.navigationBar.isHidden = false
if let validImage = self.image {
self.imageView.image = validImage

View File

@ -2,6 +2,12 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPhotoLibraryUsageDescription</key>
<string>CameraManager will access your photo library to save pictures/video.</string>
<key>NSMicrophoneUsageDescription</key>
<string>CameraManager will use your microphone to record audio for videos.</string>
<key>NSCameraUsageDescription</key>
<string>CameraManager will use your camera to take pictures/video.</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>

View File

@ -33,32 +33,32 @@ class ViewController: UIViewController {
cameraManager.showAccessPermissionPopupAutomatically = false
askForPermissionsButton.hidden = true
askForPermissionsLabel.hidden = true
askForPermissionsButton.isHidden = true
askForPermissionsLabel.isHidden = true
let currentCameraState = cameraManager.currentCameraStatus()
if currentCameraState == .NotDetermined {
askForPermissionsButton.hidden = false
askForPermissionsLabel.hidden = false
} else if (currentCameraState == .Ready) {
if currentCameraState == .notDetermined {
askForPermissionsButton.isHidden = false
askForPermissionsLabel.isHidden = false
} else if (currentCameraState == .ready) {
addCameraToView()
}
if !cameraManager.hasFlash {
flashModeButton.enabled = false
flashModeButton.setTitle("No flash", forState: UIControlState.Normal)
flashModeButton.isEnabled = false
flashModeButton.setTitle("No flash", for: UIControlState())
}
}
override func viewWillAppear(animated: Bool) {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.navigationBar.hidden = true
navigationController?.navigationBar.isHidden = true
cameraManager.resumeCaptureSession()
}
override func viewWillDisappear(animated: Bool) {
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
cameraManager.stopCaptureSession()
}
@ -66,90 +66,95 @@ class ViewController: UIViewController {
// MARK: - ViewController
private func addCameraToView()
fileprivate func addCameraToView()
{
cameraManager.addPreviewLayerToView(cameraView, newCameraOutputMode: CameraOutputMode.VideoWithMic)
cameraManager.addPreviewLayerToView(cameraView, newCameraOutputMode: CameraOutputMode.videoWithMic)
cameraManager.showErrorBlock = { [weak self] (erTitle: String, erMessage: String) -> Void in
let alertController = UIAlertController(title: erTitle, message: erMessage, preferredStyle: .Alert)
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: { (alertAction) -> Void in }))
let alertController = UIAlertController(title: erTitle, message: erMessage, preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: { (alertAction) -> Void in }))
self?.presentViewController(alertController, animated: true, completion: nil)
self?.present(alertController, animated: true, completion: nil)
}
}
// MARK: - @IBActions
@IBAction func changeFlashMode(sender: UIButton)
@IBAction func changeFlashMode(_ sender: UIButton)
{
switch (cameraManager.changeFlashMode()) {
case .Off:
sender.setTitle("Flash Off", forState: UIControlState.Normal)
case .On:
sender.setTitle("Flash On", forState: UIControlState.Normal)
case .Auto:
sender.setTitle("Flash Auto", forState: UIControlState.Normal)
case .off:
sender.setTitle("Flash Off", for: UIControlState())
case .on:
sender.setTitle("Flash On", for: UIControlState())
case .auto:
sender.setTitle("Flash Auto", for: UIControlState())
}
}
@IBAction func recordButtonTapped(sender: UIButton) {
@IBAction func recordButtonTapped(_ sender: UIButton) {
switch (cameraManager.cameraOutputMode) {
case .StillImage:
cameraManager.capturePictureWithCompletition({ (image, error) -> Void in
let vc: ImageViewController? = self.storyboard?.instantiateViewControllerWithIdentifier("ImageVC") as? ImageViewController
if let validVC: ImageViewController = vc {
if let capturedImage = image {
validVC.image = capturedImage
self.navigationController?.pushViewController(validVC, animated: true)
case .stillImage:
cameraManager.capturePictureWithCompletion({ (image, error) -> Void in
if let errorOccured = error {
self.cameraManager.showErrorBlock("Error occurred", errorOccured.localizedDescription)
}
else {
let vc: ImageViewController? = self.storyboard?.instantiateViewController(withIdentifier: "ImageVC") as? ImageViewController
if let validVC: ImageViewController = vc {
if let capturedImage = image {
validVC.image = capturedImage
self.navigationController?.pushViewController(validVC, animated: true)
}
}
}
})
case .VideoWithMic, .VideoOnly:
sender.selected = !sender.selected
sender.setTitle(" ", forState: UIControlState.Selected)
sender.backgroundColor = sender.selected ? UIColor.redColor() : UIColor.greenColor()
if sender.selected {
case .videoWithMic, .videoOnly:
sender.isSelected = !sender.isSelected
sender.setTitle(" ", for: UIControlState.selected)
sender.backgroundColor = sender.isSelected ? UIColor.red : UIColor.green
if sender.isSelected {
cameraManager.startRecordingVideo()
} else {
cameraManager.stopRecordingVideo({ (videoURL, error) -> Void in
cameraManager.stopVideoRecording({ (videoURL, error) -> Void in
if let errorOccured = error {
self.cameraManager.showErrorBlock(erTitle: "Error occurred", erMessage: errorOccured.localizedDescription)
self.cameraManager.showErrorBlock("Error occurred", errorOccured.localizedDescription)
}
})
}
}
}
@IBAction func outputModeButtonTapped(sender: UIButton) {
@IBAction func outputModeButtonTapped(_ sender: UIButton) {
cameraManager.cameraOutputMode = cameraManager.cameraOutputMode == CameraOutputMode.VideoWithMic ? CameraOutputMode.StillImage : CameraOutputMode.VideoWithMic
cameraManager.cameraOutputMode = cameraManager.cameraOutputMode == CameraOutputMode.videoWithMic ? CameraOutputMode.stillImage : CameraOutputMode.videoWithMic
switch (cameraManager.cameraOutputMode) {
case .StillImage:
cameraButton.selected = false
cameraButton.backgroundColor = UIColor.greenColor()
sender.setTitle("Image", forState: UIControlState.Normal)
case .VideoWithMic, .VideoOnly:
sender.setTitle("Video", forState: UIControlState.Normal)
case .stillImage:
cameraButton.isSelected = false
cameraButton.backgroundColor = UIColor.green
sender.setTitle("Image", for: UIControlState())
case .videoWithMic, .videoOnly:
sender.setTitle("Video", for: UIControlState())
}
}
@IBAction func changeCameraDevice(sender: UIButton) {
@IBAction func changeCameraDevice(_ sender: UIButton) {
cameraManager.cameraDevice = cameraManager.cameraDevice == CameraDevice.Front ? CameraDevice.Back : CameraDevice.Front
cameraManager.cameraDevice = cameraManager.cameraDevice == CameraDevice.front ? CameraDevice.back : CameraDevice.front
switch (cameraManager.cameraDevice) {
case .Front:
sender.setTitle("Front", forState: UIControlState.Normal)
case .Back:
sender.setTitle("Back", forState: UIControlState.Normal)
case .front:
sender.setTitle("Front", for: UIControlState())
case .back:
sender.setTitle("Back", for: UIControlState())
}
}
@IBAction func askForCameraPermissions(sender: UIButton) {
@IBAction func askForCameraPermissions(_ sender: UIButton) {
cameraManager.askUserForCameraPermissions({ permissionGranted in
self.askForPermissionsButton.hidden = true
self.askForPermissionsLabel.hidden = true
cameraManager.askUserForCameraPermission({ permissionGranted in
self.askForPermissionsButton.isHidden = true
self.askForPermissionsLabel.isHidden = true
self.askForPermissionsButton.alpha = 0
self.askForPermissionsLabel.alpha = 0
if permissionGranted {
@ -158,15 +163,15 @@ class ViewController: UIViewController {
})
}
@IBAction func changeCameraQuality(sender: UIButton) {
@IBAction func changeCameraQuality(_ sender: UIButton) {
switch (cameraManager.changeQualityMode()) {
case .High:
sender.setTitle("High", forState: UIControlState.Normal)
case .Low:
sender.setTitle("Low", forState: UIControlState.Normal)
case .Medium:
sender.setTitle("Medium", forState: UIControlState.Normal)
case .high:
sender.setTitle("High", for: UIControlState())
case .low:
sender.setTitle("Low", for: UIControlState())
case .medium:
sender.setTitle("Medium", for: UIControlState())
}
}
}