Last active
August 29, 2015 14:24
-
-
Save adajos/8ba002e738dfcbfacafc to your computer and use it in GitHub Desktop.
Swift's Enumerate Awesomeness
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
import UIKit | |
let scaleValues = ["10 feet", "100 feet", "100 yards", "400 yards", "800 yard", "1200 yards", "1 mile"] | |
var scaleLabels = [UILabel]() | |
for (scaleValueIndex, scaleValue) in scaleValues.enumerate() { | |
var label = UILabel(frame: CGRectMake((CGFloat(scaleValueIndex) + 1 * 100), 10, 100, 25)) | |
label.text = scaleValue | |
label.backgroundColor = UIColor.yellowColor() | |
label.textColor = scaleValueIndex % 2 == 0 ? UIColor.redColor() : UIColor.blackColor() | |
scaleLabels.append(label) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment