Skip to content

Instantly share code, notes, and snippets.

View kjkasi's full-sized avatar
🎯
Focusing

kjkasi

🎯
Focusing
View GitHub Profile
+ (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;
}
1) #import <MagicalRecord/MagicalRecord.h>
2) in didFinishLaunchingWithOptions [MagicalRecord setupAutoMigratingCoreDataStack];
3) in [MagicalRecord cleanUp];
/**
* 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)
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);
@kjkasi
kjkasi / UILabel+Size.m
Created May 18, 2015 19:56
UILabel+Size
- (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};