Skip to content

Instantly share code, notes, and snippets.

@shadcn
shadcn / gist:de147c42d7b3063ef7bc
Last active September 17, 2022 11:50
Convert a Hex string to UIColor in Swift
// Creates a UIColor from a Hex string.
func colorWithHexString (hex:String) -> UIColor {
var cString:String = hex.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()).uppercaseString
if (cString.hasPrefix("#")) {
cString = cString.substringFromIndex(1)
}
if (countElements(cString) != 6) {
return UIColor.grayColor()
@lamprosg
lamprosg / social.h
Last active January 3, 2016 14:03
(iOS) iOS6 Social framework
Official Twitter API (Has all the service URLs)
https://dev.twitter.com/docs/api/1.1
#import <Foundation/Foundation.h>
#import <Social/Social.h>
#import <Accounts/Accounts.h>
//Twitter GET USER INFO Service URL
//https://dev.twitter.com/docs/api/1.1/get/users/show
#define TWITTERGETUSERINFOURL @"https://api.twitter.com/1.1/users/show.json"