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
+ (CGFloat)heightForCellWithPost:(Post *)post { | |
return (CGFloat)fmaxf(70.0f, (float)[self detailTextHeight:post.text] + 45.0f); | |
} | |
+ (CGFloat)detailTextHeight:(NSString *)text { | |
CGRect rectToFit = [text boundingRectWithSize:CGSizeMake(240.0f, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:12.0f]} context:nil]; | |
return rectToFit.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
1) #import <MagicalRecord/MagicalRecord.h> | |
2) in didFinishLaunchingWithOptions [MagicalRecord setupAutoMigratingCoreDataStack]; | |
3) in [MagicalRecord cleanUp]; |
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
/** | |
* Algorithm: fixed-partition | |
* | |
* The algorithm outlined by Johannes Treitz in "The algorithm | |
* for a perfectly balanced photo gallery" (see url below). | |
* | |
* Options: | |
* - containerWidth Width of the parent container (in pixels) | |
* - idealElementHeight Ideal element height (in pixels) | |
* - spacing Spacing between items (in pixels) |
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
CABasicAnimation *cornerAnim = [CABasicAnimation animationWithKeyPath:@"cornerRadius"]; | |
cornerAnim.fromValue = @(0.f); | |
cornerAnim.toValue = @(50.f); | |
cornerAnim.duration = 0.5f; | |
[self.redView.layer addAnimation:cornerAnim forKey:@"cornerRadius"]; | |
self.redView.layer.cornerRadius = 50.f; | |
[UIView animateWithDuration:1.0f animations:^{ | |
self.redView.transform = CGAffineTransformMakeRotation(M_PI); |
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
- (CGSize)calculateSize { | |
NSShadow* shadow = [[NSShadow alloc] init]; | |
shadow.shadowOffset = self.shadowOffset; | |
NSMutableParagraphStyle* paragraph = [[NSMutableParagraphStyle alloc] init]; | |
[paragraph setLineBreakMode:self.lineBreakMode]; | |
[paragraph setAlignment:self.textAlignment]; | |
NSDictionary *attrDict = @{NSFontAttributeName: self.font, NSShadowAttributeName: shadow, NSParagraphStyleAttributeName: paragraph}; |
NewerOlder