Today, we’re going to build a simple iOS 10 best Flashlight app for iPhone. This iOS app tutorial contains absolutely no complex design. However, if you wish to add some interactive animations or something, you can design the flashlight mobile app with a graphic design software such as Photoshop.
Let’s Get Started
Create a new project under file menu and select “Single View Application.”
In the next tab, modify your project details and click on submit.
Now, add a button in your Main.Storyboard ViewController
Set a click event “actionTorchClick”
Next, import AVFoundation in ViewController.swift
Declare a boolean variable ‘is Torch’ to turn ON/OFF the torch.
Var isTorch = false
Now integrate the code snippet to touch ON/OFF in “actionTorchClick” method.
@IBAction func actionTorchClick(sender: AnyObject) { guard let device = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo) else { return } if device.hasTorch { isTourch = !isTourch do { try device.lockForConfiguration() if isTourch == true { device.torchMode = .On } else { device.torchMode = .Off } device.unlockForConfiguration() } catch { print("Torch is not working.") } } else { print("Torch not compatible with device.") } }
And Done!
Simple right? However, it’s also possible to adjust the flashlight’s brightness with couple of tweaks in the source code. And if you don’t know where the flashlight feature can be used, well the answer is, Photo editing apps.
Yes, if you might have already noticed that all of them provide an in-app camera with all features including flashlight control. So while developing a photo editing application or flashlight in iPhone, it’s possible to include flashlight feature so that users can capture better quality pictures. And if you need to create an iOS app from scratch, write down your app requirements, hire swift developer, and execute your startup plan.
Grab a free copy of iPhone Flashlight app demo from Github.
You may also like,
This page was last edited on January 11th, 2021, at 3:08.