Skip to content

Instantly share code, notes, and snippets.

View hlxwell's full-sized avatar
⛷️
Focusing

Michael He hlxwell

⛷️
Focusing
View GitHub Profile
@hlxwell
hlxwell / cgrect_to_nsarray.m
Created March 25, 2013 02:21
Store CGxxxx into Array or Dictionary
NSMutableArray* array = [NSMutableArray mutableArray];
[array addObject:[NSValue valueWithCGRect:CGRectMake(0,0,10,10)]];
CGRect someRect = [[array objectAtIndex:0] CGRectValue];
@hlxwell
hlxwell / new_gist_file
Created March 25, 2013 03:05
Round Corner
view.layer.cornerRadius = 10.0f;
@hlxwell
hlxwell / new_gist_file
Created March 25, 2013 03:05
Add shadow to UIView
_subtitleTextView.layer.shadowOffset = CGSizeMake(3.0f, 3.0f);
_subtitleTextView.layer.shadowColor = [[UIColor blackColor] CGColor];
_subtitleTextView.layer.shadowOpacity = 1.0f;
_subtitleTextView.layer.shadowRadius = 0.0f;
_subtitleTextView.textColor = [UIColor whiteColor];
_subtitleTextView.alpha = 1.0;
@hlxwell
hlxwell / new_gist_file
Created March 25, 2013 06:24
UIAlertView+Block Usage
UIAlertView *alertView = [UIAlertView alertViewWithTitle:@"Alert" message:@"Are you sure?"];
[alertView addButtonWithTitle:@"Yes" handler:^{
// YES
}];
[alertView addButtonWithTitle:@"No" handler:^{
// NO
}];
[alertView show];
@hlxwell
hlxwell / new_gist_file
Created March 28, 2013 12:25
Delayed execution objective-c
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_current_queue(), ^{
//// will be executed after 1 second
});
@hlxwell
hlxwell / macros.h
Created March 29, 2013 07:24
Macros for iOS
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
#define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
#define CurrentSystemVersion ([[UIDevice currentDevice] systemVersion])
#define CurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])
//use dlog to print while in debug model
#ifdef DEBUG
# define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
@hlxwell
hlxwell / new_gist_file
Created April 3, 2013 09:43
To see how many font names fo one font family
NSLog(@"%@", [UIFont fontNamesForFamilyName:@"Helvetica"]);
@hlxwell
hlxwell / new_gist_file
Created April 4, 2013 02:52
get font size of label
NSString *fontName = self.label.font.fontName;
CGFloat fontSize = self.label.font.pointSize;
@hlxwell
hlxwell / new_gist_file.m
Created April 4, 2013 09:02
CoreData Sort through Relationship
NSSortDescriptor *sortNameDescriptor = [[NSSortDescriptor alloc] initWithKey:@"firstName" ascending:YES];
[company.workers sortedArrayUsingDescriptors:@[sortNameDescriptor]];
@hlxwell
hlxwell / new_gist_file
Created April 9, 2013 06:44
count the line of code and exclude some folder
find . ! -wholename '*Vendor*' -name "*.h" -exec cat {} \; | wc -l