UITextView is a scrollable, multiline text region and its object : “textContainer” defines where the text will be laid out. Continue reading “Remove top padding from UITextView”
Add gradient background to UIView using CAGradientLayer
CAGradientLayer is a layer that draws gradient color over its background.
By default color are spread evenly but you can control the locations of them.
The following function will add a gradient layer to the view passed to it Continue reading “Create UIView with gradient background”
A list of all fonts in iOS and learn how to get them in Swift
This is a list of all font names in iOS and how to get them Continue reading “All font names provided by iOS”
Easily detect the absence of value in variable or constant using Optionals
Optional is an enum that has 2 states, the first state is where there is a value and that value is of some type for example Int, and the other state is nil where there is no value at all. Continue reading “Optionals in Swift”
As an iOS developer you should know the different states of iOS app and understand the difference between them
At any given moment your iOS app will be in one of those states listed below
You app will be in this state if it was not launched yet or was terminated by the system.
This is a transition state, your app goes in Inactive state for a short time when launching it. Continue reading “Execution States of iOS Application”
Use this function to add a blur effect to UIImage in Swift
Blur effect using CoreImage
First import CoreImage framework Continue reading “Add blur effect to image in Swift”
The favorite interviewer’s question for iOS developers
What is the difference between Atomic and Nonatomic properties in iOS
This has been the favorite question in iOS developer job interviews for many years.
And it is also the first question a beginner iOS developer ask once he sees the declaration of a property in Xcode like this:
@property (nonatomic , strong) NSString *firstName;
The short answer is: Continue reading “Atomic and Nonatomic properties in Objective C”
Observe and respond to property changes
What is Property Observer
Property Observer observe and respond to changes in property’s value.
It is called every time a property’s value is set, even if the new value is the same as the old value. Continue reading “Property Observer in Swift”
Swift version of Enum is much more powerful
What is Enum
Enum is a data structure that can only has discrete values.
It is always used if you need to store a group of related values like directions on map or compass(North, East, West, South), status of download process (Completed, Cancelled, Paused, Downloading) and so on. Continue reading “Beginner’s guide to Enum in Swift”
Customize every single character in your string
What is NSAttributedString
It is an object that manages string and associated set of attributes applied to individual characters or range of characters.
It is a class belongs to the Foundation framework and it is NOT a subclass of NSString. Instead it contains NSString object that it applies attributes to.
The cluster has two public class NSAttributedString and NSMutableAttributedString Continue reading “iOS developer’s guide to NSAttributedString in Swift 3”