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

iOS7 #94

Open
Tippit opened this issue Nov 3, 2013 · 6 comments
Open

iOS7 #94

Tippit opened this issue Nov 3, 2013 · 6 comments

Comments

@Tippit
Copy link

Tippit commented Nov 3, 2013

KalTileView.m CGContextSelectFont sizeWithFont CGContextShowTextAtPoint Are deprecated in iOS 7 can you help please

@JackJackBauer
Copy link

Just use UILabel instead. Works like a charm. Here's the code I'm using for the date in KalTileView.m:

- (void)drawRect:(CGRect)rect...

NSUInteger n = [self.date day];
NSString *dayText = [NSString stringWithFormat:@"%lu", (unsigned long)n];

dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, adjustDateText, kTileSize.width, 20.)];
[dateLabel setBackgroundColor:[UIColor clearColor]];
dateLabel.textAlignment = NSTextAlignmentCenter;
NSDictionary *attrib = @{NSForegroundColorAttributeName : textColor,
                         NSFontAttributeName : font};

NSMutableAttributedString *attribString = [[NSMutableAttributedString alloc]initWithString:dayText attributes:attrib];

dateLabel.attributedText = attribString;

[self addSubview:dateLabel];

where adjustDateText is set to adjust the horizontal position according the device used (i.e. 3.5", 4" or iPad).

@Tippit
Copy link
Author

Tippit commented Nov 3, 2013

Thank´s you're awesome ;)

@jas54
Copy link

jas54 commented Nov 4, 2013

@JackJackBauer: Can you please share how the variable "adjustDateText" has been initialized with device dependant values

@JackJackBauer
Copy link

Sure. I'm basically just going through some tests for devices and set the variable accordingly:

in - (void)drawRect:(CGRect)rect I set NSString *device = [[UIScreen mainScreen] bounds].size.height > 480 ? @"iPhone5":@"iPhone";. You can use something like

if ([[UIDevice currentDevice]userInterfaceIdiom]==UIUserInterfaceIdiomPad)
device = [ResourceManager sharedResourceManager].isLandscape ? device = @"iPadLandscape" : device = @"iPadPortrait";

to check for iPad-layouts.

I then set a bunch of layout-variables:

float adjustDateText = 2.f; if ([device isEqualToString:@"iPhone5"]) { ... adjustDateText = 5.f; } else if ([device isEqualToString:@"iPadLandscape"]) { ... adjustDateText = 13.f; }

And while we're at it: In fact I'm even checking for my custom 6-weeks-layout there and adjust for that too (I hated the wasted display-area for moths with just 5 weeks vs. those with 6 weeks...)

BOOL is6Weeks = self.numWeeks > 5 ? TRUE : FALSE;

where I passed the number of weeks (lines) in the current month from KalGridViews
- (NSInteger)numberOfWeeksInDisplay
{
return (NSInteger) ceilf( ([logic.daysInFinalWeekOfPreviousMonth count] + [logic.daysInSelectedMonth count] + [logic.daysInFirstWeekOfFollowingMonth count])/ 7.f);
}

though KalMonthView.m

BTW the whole layout is easily customizable to a iOS7-like flat layout with the proper use of flat images and fonts. :-)

@jas54
Copy link

jas54 commented Nov 4, 2013

thanks for the response.

But unfortunately this method is only working for the initial month view in the calendar. for the next month or previous month views, the date texts are overlapping. Is there any reset need to the label frame?

@JackJackBauer
Copy link

Hmm... I do not see any overlapping. But then I worked with the project and customized it for about 2 1/2 years now so there really isn't much left from the original ;-)

As I see it, when you make the changes to KalTileView.m it should affect all instances of those - i.e. all tiles. Not just those of the initial month, because all tiles are based on KalTileView.

What do you show in the tiles? Just the date as a number? What does it look like when these are overlapping?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants