This file contains hidden or 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
+(UIImage*)TakeScreenshotOfView:(UIView*)view Cropping:(CGRect)dimensions | |
{ | |
CGFloat scale = 1.0f; | |
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) | |
scale = [[UIScreen mainScreen] scale]; | |
UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, scale); | |
[view.layer renderInContext:UIGraphicsGetCurrentContext()]; |
This file contains hidden or 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
- (void)resizeLoginView:(FBLoginView*)loginview | |
{ | |
for(UIView * view in loginview.subviews) | |
{ | |
if([view isKindOfClass:[UILabel class]]) | |
{ | |
view.frame = CGRectMake( view.frame.origin.x-23, view.frame.origin.y, view.frame.size.width/2, view.frame.size.height /2); | |
} | |
else | |
{ |
This file contains hidden or 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
//center horizontally or vertically | |
subView.center = CGPointMake(parentView.frame.size.width / 2, parentView.frame.size.height / 2); | |
//center horizontally + vertically | |
subView.center = [parentView convertPoint:parentView.center fromView:parentView.superview]; |
This file contains hidden or 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
-(void)addBox | |
{ | |
self.layer.masksToBounds = NO; | |
CALayer *errorLayer; | |
errorLayer = [CALayer layer]; | |
errorLayer.backgroundColor = [UIColor blueColor].CGColor; | |
errorLayer.frame = CGRectMake(0,0, self.frame.size.width, self.frame.size.height); | |
errorLayer.cornerRadius = 0.0f; | |
CALayer *bgLayer = [CALayer layer]; | |
bgLayer.frame = errorLayer.frame; |
This file contains hidden or 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
- (void)scrollViewDidScroll:(UIScrollView *)scrollView | |
{ | |
if (scrollView.contentOffset.y < -50) | |
{ | |
scrollView.contentOffset = CGPointMake(0, -50); | |
} | |
} |
This file contains hidden or 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
-(void)scrollViewDidScroll:(UIScrollView *)scrollView | |
{ | |
float scrollOffsetY = scrollView.contentOffset.y; | |
if(scrollOffsetY < 0) | |
{ | |
//Pulling down | |
} | |
else if(scrollOffsetY > scrollView.contentSize.height - scrollView.frame.size.height) | |
{ |
This file contains hidden or 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
[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil]; |
This file contains hidden or 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
//Modified from http://stackoverflow.com/questions/8533691/how-to-get-all-nsrange-of-a-particular-character-in-a-nsstring | |
- (NSMutableAttributedString*) setColor:(UIColor*)color word:(NSString*)word inText:(NSMutableAttributedString*)mutableAttributedString { | |
NSUInteger count = 0, length = [mutableAttributedString length]; | |
NSRange range = NSMakeRange(0, length); | |
while(range.location != NSNotFound) | |
{ | |
range = [[mutableAttributedString string] rangeOfString:word options:0 range:range]; |
This file contains hidden or 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
//http://stackoverflow.com/questions/12748911/do-things-when-back-button-is-pressed | |
-(void)viewWillDisappear:(BOOL)animated { | |
NSUInteger ind = [[self.navigationController viewControllers] indexOfObject:self]; | |
if (ind == NSNotFound) { | |
// do something, we're coming off the stack. | |
} | |
} |
This file contains hidden or 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
OlderNewer