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
extension UITextField { | |
public override func drawPlaceholderInRect(rect: CGRect) { | |
let newColor = UIColor(white: 1, alpha: 0.4) | |
let range = NSMakeRange(0, self.attributedPlaceholder!.length) | |
var mutatedAttributedPlaceholder = NSMutableAttributedString(attributedString: self.attributedPlaceholder!) | |
mutatedAttributedPlaceholder.setAttributes([ NSForegroundColorAttributeName : newColor ], range: range) | |
self.attributedPlaceholder = mutatedAttributedPlaceholder | |
super.drawPlaceholderInRect(rect) |
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
let randomBgColor = UIColor(red: CGFloat(drand48()), green: CGFloat(drand48()), blue: CGFloat(drand48()), alpha: 1) |
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
// Disable blink caret inspired from Joseph Chiu's answer on | |
// http://stackoverflow.com/questions/3699727/hide-the-cursor-of-an-uitextfield | |
extension UITextField { | |
public override func caretRectForPosition(position: UITextPosition!) -> CGRect { | |
if <# condition for hidden blink #> { | |
return CGRectZero | |
} | |
return super.caretRectForPosition(position) | |
} |
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
// Inspiration from | |
// http://stackoverflow.com/questions/28644311/howto-get-the-rgb-code-int-from-an-uicolor-in-swift | |
// http://stackoverflow.com/questions/24074257/how-to-use-uicolorfromrgb-value-in-swift | |
func UIColorFromRGB(rgbValue: UInt) -> UIColor { | |
return UIColor( | |
red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0, | |
green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0, | |
blue: CGFloat(rgbValue & 0x0000FF) / 255.0, | |
alpha: CGFloat(1.0)) |
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
/** | |
Host: Staging => http://staging.myblog.com/api, Production => https://myblog.com/api | |
Method: /blog | |
Read blog — GET /blog/:id | |
Create blog — POST /blog, body: title=<string>&body=<string> | |
Update blog — UPDATE /blog/:id, body: title=<string>&body=<string> | |
Delete blog — DELETE /blog:id | |
*/ | |
enum BlogMethod { |
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
enum Host { | |
case Staging = “http://staging.myblog.com/api” | |
case Production = “https://myblog.com/api” | |
} | |
class API { | |
class var host: Host | |
func blog(…) -> (…) { | |
let apiPath = “\(API.host.rawValue)/blog” | |
... |
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
let api = API() | |
let blogID = "1" | |
let title = "Hello my blog" | |
let body = "Hello world, this is my first blog entry" | |
// Create blog | |
api.blog(.CREATE(title, body)) | |
// Read blog |
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
// (1) | |
// Get report by month | |
// without Enum | |
-(Report *)reportFor:(int)month { | |
... | |
} | |
Report *reportMay = self.reportFor(5) // Report for May |
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
platform :ios, '8.0' | |
use_frameworks! | |
target 'SMSME' do | |
end | |
target 'SMSMETests' do | |
pod 'Quick', '~> 0.3.1' ## For Swift 1.2 | |
pod 'Nimble' | |
end |
OlderNewer