Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS method compatibility update #43

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions PopoverView/PopoverView.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,13 @@ - (CGSize) screenSize
- (void)showAtPoint:(CGPoint)point inView:(UIView *)view withText:(NSString *)text
{
UIFont *font = kTextFont;

CGSize screenSize = [self screenSize];
CGSize textSize = [text sizeWithFont:font constrainedToSize:CGSizeMake(screenSize.width - kHorizontalMargin*4.f, 1000.f) lineBreakMode:UILineBreakModeWordWrap];
CGRect textRect = [text boundingRectWithSize:CGSizeMake(screenSize.width - kHorizontalMargin*4.f, 1000.f)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{NSFontAttributeName:font}
context:nil];

CGSize textSize = textRect.size;

UILabel *textView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, textSize.width, textSize.height)];
textView.backgroundColor = [UIColor clearColor];
Expand All @@ -180,7 +184,12 @@ - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withTitle:(NSString *)t
UIFont *font = kTextFont;

CGSize screenSize = [self screenSize];
CGSize textSize = [text sizeWithFont:font constrainedToSize:CGSizeMake(screenSize.width - kHorizontalMargin*4.f, 1000.f) lineBreakMode:UILineBreakModeWordWrap];
CGRect textRect = [text boundingRectWithSize:CGSizeMake(screenSize.width - kHorizontalMargin*4.f, 1000.f)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{NSFontAttributeName:font}
context:nil];

CGSize textSize = textRect.size;

UILabel *textView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, textSize.width, textSize.height)];
textView.backgroundColor = [UIColor clearColor];
Expand Down Expand Up @@ -269,7 +278,8 @@ - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withTitle:(NSString *)t
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];

//Create a label for the title text.
CGSize titleSize = [title sizeWithFont:kTitleFont];
CGSize titleSize = [title sizeWithAttributes:@{NSFontAttributeName:kTitleFont}];
//CGSize size = [string sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17.0f]}];
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.f, 0.f, titleSize.width, titleSize.height)];
titleLabel.backgroundColor = [UIColor clearColor];
titleLabel.font = kTitleFont;
Expand Down Expand Up @@ -356,7 +366,7 @@ - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withStringArray:(NSArra
UIFont *font = kTextFont;

for (NSString *string in stringArray) {
CGSize textSize = [string sizeWithFont:font];
CGSize textSize = [string sizeWithAttributes:@{NSFontAttributeName:font}];
UIButton *textButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, textSize.width, textSize.height)];
textButton.backgroundColor = [UIColor clearColor];
textButton.titleLabel.font = font;
Expand All @@ -381,7 +391,7 @@ - (void)showAtPoint:(CGPoint)point inView:(UIView *)view withTitle:(NSString *)t
UIFont *font = kTextFont;

for (NSString *string in stringArray) {
CGSize textSize = [string sizeWithFont:font];
CGSize textSize = [string sizeWithAttributes:@{NSFontAttributeName:kTitleFont}];
UIButton *textButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, textSize.width, textSize.height)];
textButton.backgroundColor = [UIColor clearColor];
textButton.titleLabel.font = font;
Expand Down Expand Up @@ -428,7 +438,7 @@ - (NSMutableArray*) makeTempViewsWithStrings:(NSArray *)stringArray andImages:(N
NSString *string = [stringArray objectAtIndex:i];

//First we build a label for the text to set in.
CGSize textSize = [string sizeWithFont:font];
CGSize textSize = [string sizeWithAttributes:@{NSFontAttributeName:font}];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, textSize.width, textSize.height)];
label.backgroundColor = [UIColor clearColor];
label.font = font;
Expand Down