View abc.js
This file contains 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
console.log('abc'); |
View UIView+Bounce
This file contains 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)bounceAnimation:(void (^)())completion | |
{ | |
CGRect rect = self.frame; | |
CGRect insetRect = CGRectInset(rect, 10, 10); | |
self.frame = insetRect; | |
[UIView animateWithDuration:1 delay:0 usingSpringWithDamping:0.4 initialSpringVelocity:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ | |
self.frame = rect; | |
} completion:^(BOOL finished) { |
View Drawrect Animation
This file contains 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)setHighlighted:(BOOL)highlighted animated:(BOOL)animated{ | |
[super setHighlighted:highlighted]; | |
[self setNeedsDisplay]; | |
if (animated) { | |
[UIView transitionWithView:self duration:0.1 | |
options:UIViewAnimationOptionTransitionCrossDissolve | |
animations:^{ | |
[self.layer displayIfNeeded]; | |
} completion:nil]; | |
} |
View Fast Rendering
This file contains 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
UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, self.window.screen.scale); | |
[self.imageView drawViewHierarchyInRect:self.frame afterScreenUpdates:YES]; | |
UIImage *snapshotImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); |
View iOS7 default animation
This file contains 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
[UIView animateWithDuration:0.5f delay:0 usingSpringWithDamping:1 initialSpringVelocity:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{ | |
//animation | |
} completion:^(BOOL finished) { | |
//completion | |
}]; |
View gist:10703171
This file contains 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
CATransition *animation = [CATransition animation]; | |
[animation setType:kCATransitionPush]; | |
[animation setSubtype:kCATransitionFade]; | |
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; | |
[animation setFillMode:kCAFillModeBoth]; | |
[animation setDuration:.05]; | |
[collectionView.layer addAnimation:animation forKey:kCATransition]; |
View gist:ca28e3c96b76d3c6cf18
This file contains 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)controllerWillChangeContent:(NSFetchedResultsController *)controller | |
{ | |
self.shouldReloadCollectionView = NO; | |
self.blockOperation = [[NSBlockOperation alloc] init]; | |
} | |
- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id<NSFetchedResultsSectionInfo>)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type | |
{ | |
__block UICollectionView *collectionView = self.collectionView; | |
switch (type) { | |
case NSFetchedResultsChangeInsert: { |
View 0_reuse_code.js
This file contains 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 |
View gist:a50c0cfbe4931016145b
This file contains 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
def findAllFiles(path): | |
for root, dirs, files in os.walk(os.path.expanduser(path)): | |
yield root | |
for file in files: | |
yield os.path.join(root, file) | |
for file in findAllFiles(''): | |
print (file) |
View gist:d818a80e7fb0ab176c63
This file contains 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
+ (CGFloat)heightOfCellWithTableView:(UITableView *)tableView obj:(id)obj | |
{ | |
static MMCell *sizingCell = nil; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
sizingCell = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; | |
}); | |
sizingCell.obj = obj; | |
CGSize size = [sizingCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize]; | |
return size.height; |
OlderNewer