ios - Translate this line in Swift 2.0 to English -
i have ran line of code in infamous sevenswitch class.
here line...
backgroundview.layer.cornerradius = self.isrounded ? frame.size.height * 0.4 : 2
i don't understand ?
or :
@ end of equation. please explain these mean , how used?
thanks bunch!
operators can unary, binary, or ternary:
this ternary operators operate on 3 targets. c, swift has 1 ternary operator, ternary conditional operator (a ? b : c).
from apple documents basic operators
ternary conditional operator
the ternary conditional operator special operator 3 parts, takes form question ? answer1 : answer2. shortcut evaluating 1 of 2 expressions based on whether question true or false. if question true, evaluates answer1 , returns value; otherwise, evaluates answer2 , returns value.
as per question if isround
true corner radios frame.size.height
else it's 2.
as if condition :
if(self.isrounded){ backgroundview.layer.cornerradius = frame.size.height * 0.4 } else{ backgroundview.layer.cornerradius = 2.0 }
Comments
Post a Comment