Skip to content

Instantly share code, notes, and snippets.

View muukii's full-sized avatar
✈️
We live in a twilight world.

Hiroshi Kimura muukii

✈️
We live in a twilight world.
View GitHub Profile
@muukii
muukii / abc.js
Created December 6, 2013 15:43
test.js
console.log('abc');
@muukii
muukii / UIView+Bounce
Created February 10, 2014 09:40
UIView bounce Animation
- (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) {
@muukii
muukii / Drawrect Animation
Created February 10, 2014 13:08
Drawrect Animation
- (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];
}
UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, self.window.screen.scale);
[self.imageView drawViewHierarchyInRect:self.frame afterScreenUpdates:YES];
UIImage *snapshotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
@muukii
muukii / iOS7 default animation
Created April 12, 2014 07:44
iOS7 default animation
[UIView animateWithDuration:0.5f delay:0 usingSpringWithDamping:1 initialSpringVelocity:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
//animation
} completion:^(BOOL finished) {
//completion
}];
@muukii
muukii / gist:10703171
Last active August 29, 2015 13:59
UIColleciton-TableView ReloadData
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];
@muukii
muukii / gist:ca28e3c96b76d3c6cf18
Last active August 29, 2015 14:00
NSFetchedResultsControllerDelegate with UICollectionView
- (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: {
@muukii
muukii / 0_reuse_code.js
Created May 23, 2014 12:42
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@muukii
muukii / gist:a50c0cfbe4931016145b
Last active August 29, 2015 14:01
Python 全ファイル表示
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)
@muukii
muukii / gist:d818a80e7fb0ab176c63
Created July 19, 2014 10:00
Autolayout : UITableViewCell : size
+ (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;