Comments (6)
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.
Thank´s you're awesome ;)
from kal.
@JackJackBauer: Can you please share how the variable "adjustDateText" has been initialized with device dependant values
from kal.
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.
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.
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)
- event adding into calendar
- Set bounds to Kal Calendar
- View Controller Scene HOT 3
- Change format date of title HOT 1
- How to localize the Day names ? HOT 1
- ios 10 HOT 2
- Weird Extra Days in Calendar for iPhone 6/7 and 6/7 Plus Not other Devices HOT 2
- License
- Implementing Week View and Day View !!! HOT 1
- How to remove separator line between cells HOT 1
- How to increase the uitableview height? HOT 2
- iOS 7 design HOT 9
- JSON Format?
- Weekdays only? HOT 1
- Is there any other drop in solution instead of drag whole Kal project into my project?
- Deselecting a date?
- Deselecting a date?
- iOS7 Support - Date Header missing HOT 1
- Problem with 4-inches screens HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kal.