iOS  Tree

"All of us do not have equal talent. But , all of us have an equal opportunity to develop our talents.” – A.P.J Abdul Kalam

iOS Blinking/Flashing label — November 21, 2017

iOS Blinking/Flashing label

Objective C:
yourLabelName.alpha = 1.0f;// yourLabelName
[UIView animateWithDuration:0.8 delay:0.0 options:
                    UIViewAnimationOptionCurveEaseInOut |
                    UIViewAnimationOptionRepeat |
                    UIViewAnimationOptionAutoreverse |
                    UIViewAnimationOptionAllowUserInteraction
                    animations:^{
                      yourLabelName.alpha = 0.0f;// yourLabelName
                     }
completion:^(BOOL finished){
                             // Do nothing
}];

Swift:
extension UILabel {
            //MARK: StartBlink
            func startBlink() {
                      UIView.animate(withDuration: 0.8,//Time duration
                                    delay:0.0,
                                    options:[.allowUserInteraction, .curveEaseInOut, .autoreverse, .repeat],
                                    animations: { self.alpha = 0 },
                                    completion: nil)
            }

            //MARK: StopBlink
            func stopBlink() {
                      layer.removeAllAnimations()
                      alpha = 1
            }
}

You can change the values to get different effects.
For example:- Changing animateWithDuration will set the blinking speed, repeat will give you continuous blinking effects.
Further you can use it on anything that inherits from UIView example a UIButton, UILabel, custom view, etc.

Three double quotes ‘”””‘ in Swift — November 3, 2017

Three double quotes ‘”””‘ in Swift

Indentation at the start of each quoted line is removed, as long as it matches the indentation of the closing quote.

Example:
let quotation = """Even though there's whitespace to the left,
the actual lines aren't indented.
Except for this line.


Double quotes (") can appear without being escaped.
I still have \(apples + oranges) pieces of fruit."""

You can only use them with Xcode 9 above, Swift 4 above

Reference: Apple document – Multiline String Literals

The double question marks in Swift ?? — November 1, 2017

The double question marks in Swift ??

?? is Nil-Coalescing Operator (a ?? b) unwraps an optional a if it contains a value, or returns a default value b if a is nil. The expression a is always of an optional type.

Example:
a != nil ? a! : b
The shorthand code is
a ?? b

Example 1:
var aValue: Int? //aValue has no value
let bValue = 5
var resultValue: Int
resultValue = aValue ?? bValue
print(resultValue)
//resultValue will be 5

Example 2:
var aValue: Int? = 10 //aValue has value
let bValue = 5
var resultValue: Int
resultValue = aValue ?? bValue
print(resultValue)
//resultValue will be 10