Skip to content

Instantly share code, notes, and snippets.

View TosinAF's full-sized avatar
🧢

Tosin Afolabi TosinAF

🧢
View GitHub Profile
#python3
import itertools, datetime
def readFile(path):
""" Requires only one arguement, the path of the file to be read """
with open(path) as file: #auto closes file after
content = file.readline()
return content
@TosinAF
TosinAF / imageWithColor
Last active December 27, 2015 17:59
To Generate a UIImage of a UIColor. Useful when you want to change the background color of a UIButton
- (UIImage *)imageWithColor:(UIColor *)color {
CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();