Skip to content

Instantly share code, notes, and snippets.

@aaronksaunders
Created January 18, 2016 18:19
Show Gist options
  • Select an option

  • Save aaronksaunders/ce763bea6ca4cab08dac to your computer and use it in GitHub Desktop.

Select an option

Save aaronksaunders/ce763bea6ca4cab08dac to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
import UIKit
var str = "Hello, playground"
var myLabel:UILabel = UILabel(frame: CGRectMake(0,0,280,32))
myLabel.font = UIFont.systemFontOfSize(32.0)
/**
testing so I can use markdown
- returns: Sed do eiusmod tempor.
*/
func what()-> String{
return "help"
}
/**
testing so I can use markdown
- Parameter val: added to string
- returns: help with a new value
*/
func whatWithParam( val:Int)-> String{
return "help \(val)"
}
var myMutableString:NSMutableAttributedString;
myMutableString = NSMutableAttributedString(string:"what the what" );
myMutableString.addAttribute(NSForegroundColorAttributeName,
value: UIColor.redColor(),
range: NSRange( location:5, length:3))
// multiple attributes at once
var greenAndBold = [String:NSObject]()
greenAndBold[NSForegroundColorAttributeName] = UIColor.greenColor()
greenAndBold[NSFontAttributeName] = UIFont.boldSystemFontOfSize(32.0)
myMutableString.addAttributes(greenAndBold, range: NSRange( location:9, length:4))
myLabel.attributedText = myMutableString
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment