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
public String getImagePath(Context context, Uri uri){ | |
if ("content".equalsIgnoreCase(uri.getScheme())) { | |
if (isGoogleOldPhotosUri(uri)) { | |
// return http path, then download file. | |
return uri.getLastPathSegment(); | |
} else if (isGoogleNewPhotosUri(uri)) { | |
// copy from uri. context.getContentResolver().openInputStream(uri); | |
return copyFile(context, uri); | |
} else if (isPicasaPhotoUri(uri)) { |
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
Project | # of Top 100 Free Apps (US) | |
---|---|---|
facebook-ios-sdk | 67 | |
Bolts-iOS | 48 | |
AFNetworking | 39 | |
Google-Mobile-Ads-SDK | 38 | |
Reachability (Apple) | 38 | |
Crashlytics | 37 | |
Flurry-iOS-SDK | 31 | |
CocoaPods | 30 | |
GoogleConversionTracking | 29 |
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
- (CGRect)getMaxFrameForText:(UILabel *)label { | |
label.numberOfLines = 0; | |
label.lineBreakMode = NSLineBreakByWordWrapping; | |
CGRect currentFrame = label.frame; | |
CGSize max = CGSizeMake(label.frame.size.width, 250); | |
CGRect textRect = [label.text boundingRectWithSize:max options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:label.font} context:nil]; | |
currentFrame.size.height = ceilf(textRect.size.height); | |
return currentFrame; | |
} |
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)heightOfCellWithIngredientLine:(NSString *)ingredientLine maxSize:(CGSize)max labelFont:(UIFont*)font | |
{ | |
NSStringDrawingContext *context = [[NSStringDrawingContext alloc] init]; | |
CGRect labelRect = [ingredientLine boundingRectWithSize:max | |
options:NSStringDrawingUsesLineFragmentOrigin | |
attributes:@{NSFontAttributeName:font} | |
context:context]; | |
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
// | |
// UILabel+OKASizeCalculator.m | |
// | |
// Created by Oliver on 16/01/2014. | |
// Copyright (c) 2014 Oliver Atkinson. All rights reserved. | |
// | |
#import "UILabel+OKASizeCalculator.h" | |
@implementation UILabel (OKASizeCalculator) |
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
- (CGSize)intrinsicContentSize { | |
CGSize boundingSize = CGSizeMake(self.titleLabel.preferredMaxLayoutWidth - self.titleEdgeInsets.left - self.titleEdgeInsets.right, CGFLOAT_MAX); | |
NSAttributedString *attributedTitle = [self attributedTitleForState:self.state]; | |
CGRect boundingRect; | |
if(attributedTitle) { | |
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)heighWithFont:(UIFont *)font constrainedToSize:(CGSize)size | |
{ | |
return [self sizeWithFont:font constrainedToSize:size].height; | |
} | |
- (CGFloat)widthWithFont:(UIFont *)font constrainedToSize:(CGSize)size | |
{ | |
return [self sizeWithFont:font constrainedToSize:size].width; | |
} |
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
NSString *str = <#some string#>; | |
CGSize size; | |
CGSize maxSize = CGSizeMake(<#width#>, <#height#>); | |
UIFont *font = <#font#>; | |
if ([str respondsToSelector:@selector(boundingRectWithSize:options:attributes:context:)]) { | |
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; | |
[style setLineBreakMode:<#Line break mode#>]; | |
[style setAlignment:<#String alignment#>]; | |
NSDictionary *attributes = @{ NSFontAttributeName:font, | |
NSParagraphStyleAttributeName:style |
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) estimateHeight:(NSString *)content{ | |
NSAttributedString *bodyText = [NSAttributedString attributedStringWithMarkdownString:content font:MYCellFontDefine]; | |
CGRect rect = [bodyText boundingRectWithSize:CGSizeMake(CELL_WIDTH, FLT_MAX) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil]; | |
return CGRectGetHeight(rect); | |
} |
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
CGSize maximumLabelSize = CGSizeMake(tableView.width, MAXFLOAT); | |
NSStringDrawingOptions options = NSStringDrawingTruncatesLastVisibleLine | | |
NSStringDrawingUsesLineFragmentOrigin; | |
NSDictionary *attr = @{NSFontAttributeName: [UIFont systemFontOfSize:15]}; | |
CGRect labelBounds = [string boundingRectWithSize:maximumLabelSize | |
options:options | |
attributes:attr | |
context:nil]; |
NewerOlder