Posts

Showing posts from July, 2017

How to set Status Bar in iOS?

Image
Setting the  UIStatus Bar Style   is very simple in iOS. Below is how it looks like with lightContent Style and the Default Style. Based on the app. UIView backgroundColor, you can set the way a status bar should appear. There are two ways to achieve this. The first one being the recommended one since iOS 7. For this one would have to make changes in Info.plist. 1) In iOS 7 onwards, you can specify the bar style per view controller. For this the value for Key UIViewControllerBasedStatusBarAppearance in info.plist should be set to YES . Now in your controller you should override a property  preferredStatusBarStyle  as coded below.     override var preferredStatusBarStyle: UIStatusBarStyle {         get {             return . lightContent         }      } Changing the return to .default will give you dark status bar style. 2) So, if you are planning to use the default method which API says its Deprecated, you need to  UIViewControllerB

Swift Class versus Structure

In Swift Just like classes play a important role , Structure do play a important role. What could be the notable difference? First one is Structure is pass by value and Classes are pass by reference.  Below is a simple example to understand the meaning of it. func getAddress( _ object: Any )-> String {     var newObject = object     var address: String = String ( "Could Not CalculateAddress" )     withUnsafePointer (to: &newObject) {                  address = " \ ( $0 )"     }     return address } func getAddressForClass( _ object: AnyObject ) -> Any {     return Unmanaged < AnyObject >. passUnretained (object). toOpaque () } //Structure struct User{     var name: String     var userId: Int } func changeStructuredValue( _ inputStruct: User ){     var newInputStruct = inputStruct     newInputStruct. name =   "Rose"     print ( "Modifying Struct , Addres