iOS: First App from Apple

This entry is part 3 of 32 in the series iOS Apps

A video by Apple on how to build an iOS app in Swift language from scratch, in less than ten minutes.

Below is the source code and I am using the latest version of Swift.

import UIKit

class ViewController: UIViewController {

    @IBOutlet var photoImageView: UIImageView!
    
    let context = CIContext(options: nil)
    
    
    @IBAction func appFilter(sender: AnyObject) {
        
        let inputImage = CIImage(image: photoImageView.image!)
        
        let randomColor = [kCIInputAngleKey: (Double(arc4random_uniform(314))/100)]
        
        let filteredImage = inputImage?.imageByApplyingFilter("CIHueAdjust", withInputParameters: randomColor)
        
        let renderedImage = context.createCGImage(filteredImage!, fromRect: filteredImage!.extent)
        
        photoImageView.image = UIImage(CGImage: renderedImage)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}

 

Series Navigation<< iOS: Hello World with a text field
iOS: A simple counter >>