Skip to content

Instantly share code, notes, and snippets.

View tomisacat's full-sized avatar
🤯

tomisacat tomisacat

🤯
  • Shanghai, China
View GitHub Profile
@tomisacat
tomisacat / FRP iOS Learning resources.md
Created February 15, 2016 02:47 — forked from JaviLorbada/FRP iOS Learning resources.md
The best FRP iOS resources.

Videos

@tomisacat
tomisacat / customize_segmentcontrol.m
Created December 9, 2014 12:42
customize segment control ui style
NSDictionary *normalSettings = @{UITextAttributeTextColor: [UIColor grayColor], UITextAttributeFont: [UIFont systemFontOfSize:13]};
[self.segmentControl setTitleTextAttributes:normalSettings forState:UIControlStateNormal];
NSDictionary *highlightedSettings = @{UITextAttributeTextColor: [UIColor red:43 green:206 blue:119 alpha:1.0], UITextAttributeFont: [UIFont systemFontOfSize:16]};
[self.segmentControl setTitleTextAttributes:highlightedSettings forState:UIControlStateSelected];
@tomisacat
tomisacat / clearEllipseInRect.m
Created December 4, 2014 07:55
clear a circle/ellipse area like CGContextClearRect to clear a rect area
- (void)drawRect:(CGRect)rect
{
CGContextRef con = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(con, [UIColor grayColor].CGColor);
CGContextFillRect(con, rect);
CGContextAddEllipseInRect(con, self.circle); // self.circle is a property of CGRect
CGContextClip(con);
CGContextClearRect(con, self.circle);
}
NSString *pattern = @"([\\.\\+\\(\\)\\-\\_\\s])";
NSRegularExpression *re = [NSRegularExpression regularExpressionWithPattern:pattern options:NSRegularExpressionCaseInsensitive error:nil];
NSString *replaced = [re stringByReplacingMatchesInString:phoneNumber options:0 range:NSMakeRange(0, [phoneNumber length]) withTemplate:@""];
NSLog(@"%@", replaced);