Giter Club home page Giter Club logo

Comments (6)

JackJackBauer avatar JackJackBauer commented on June 30, 2024

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).

from kal.

Tippit avatar Tippit commented on June 30, 2024

Thank´s you're awesome ;)

from kal.

jas54 avatar jas54 commented on June 30, 2024

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

from kal.

JackJackBauer avatar JackJackBauer commented on June 30, 2024

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. :-)

from kal.

jas54 avatar jas54 commented on June 30, 2024

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?

from kal.

JackJackBauer avatar JackJackBauer commented on June 30, 2024

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?

from kal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.