Category: iOS Swift

  • Git Submodule Adding To Existing Git Project

    Git Submodule Adding To Existing Git Project

    Tidy way of adding 3rd part frameworks in your project is; First, go into project folder clon the 3rd part frameworks in this with git command below. It will create a Frameworks folder and sub folder for the desired repository. #example below for adding SwiftyJSON git submodule add https://github.com/SwiftyJSON/SwiftyJSON.git Frameworks/SwiftyJSON #example below for adding Alamofire git…

  • Playing YouTube Videos In iOS Device

      Playing a YouTube video in the app is very easy with UIWebView Here is a snippet // YouTube video  @IBOutlet weak var webView: UIWebView!     // MARK: – Embed Video Player // id is like: xjr89789234 (grab this from youtube url)     func loadYoutube(_ videoID:String) {         guard    …

  • iOS Swift Detecting Device Rotation

    How to detect device rotation event in iOS Swift 3: Detecting device rotation is not a big secret but doing this in a clean way is important. I mean adding and removing the observers in correct time/place. Many developer are adding  observers without removing with exit. This leads memory leaks and performance issues.   override func…

  • UIView With Rounded Background Designable In Storyboard

    UIView With Rounded Background Designable In Storyboard

    This class can be inherited as a base class for having any time a framed background behind the UIView. It is also designable in the Storyboard. I’ve used it in UITableViewCell for my customCell view.

  • iOS Swift 3 Playground UIButton Action

    Experimenting on Playground is very useful especially when we work on some interactive UI element like UIButton. This is a simple example that show how to use UIButton and new Swift command PlaygroundSupport (XCPlaygroundPage depreciated)

  • Swift Creating Vertical UISlider Programmatically

    Swift Creating Vertical UISlider Programmatically

    This code creating UISlider and turn 90 degrees  anticlockwise with -M_PI_2 in another context for another UIView we could use the same code with M_PI_2  for turning 90 degrees clockwise. I found this easy and useful, worth note.

  • iOS Swift Programming Patterns: Singleton

    iOS Swift Programming Patterns: Singleton

    What is Singleton Pattern? The Singleton pattern is class which initiated once itself and give global access to this created instance. As it has a unique instance, class variables and methods are shared in entire application/namespace. To understand better let’s check where we can use this pattern.

  • iOS Swift Custom Navigation Bar Color

    iOS Swift Custom Navigation Bar Color

    In Swift to change the text or top navigation are colour is not the same as UIBotton methods. The quick example below shows how to set them.