-
Notifications
You must be signed in to change notification settings - Fork 654
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
Moving calendar position #4
Comments
Do you have a screen shot? |
I think this is not a library issue, but an issue on your side. Can you prove me wrong? |
Sorry for my late response. i thought i would get an email notification in case you would respond to this. thank you very much! |
I ran into a similar issue. I overrode the necessary methods to include the ability to include a frame in the calendar. #import //UIKit/UIKit.h #import //TapkuLibrary/TapkuLibrary.h @interface TKCalendarMonthView (Framed) - (id) initWithFrame:(CGRect)frame; - (void) drawMonthLabel:(CGRect)rect; - (void) drawDayLabels:(CGRect)rect; - (void) drawRect:(CGRect)rect; @end @implementation TKCalendarMonthView (Framed) - (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { // Initialization code self.backgroundColor = [UIColor clearColor]; TKDateInformation info = [[NSDate date] dateInformation]; info.second = info.minute = info.hour = 0; info.day = 1; [self setCurrentMonth:[NSDate dateFromDateInformation:info]]; monthYear = [[NSString stringWithFormat:@"%@ %@",[currentMonth month],[currentMonth year]] copy]; [self setSelectedMonth:currentMonth]; [self loadButtons]; float hgt = CGRectGetHeight(frame) - 44; float wdt = CGRectGetWidth(frame); float oriX = CGRectGetMinX(frame); float oriY = CGRectGetMinY(frame)- 55; //where the top of the calendar will be scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(oriX, oriY, wdt, hgt)]; scrollView.contentSize = CGSizeMake(320,100); [self addSubview:scrollView]; scrollView.scrollEnabled = NO; scrollView.backgroundColor =[UIColor colorWithRed:222/255.0 green:222/255.0 blue:225/255.0 alpha:1]; shadow = [[UIImageView alloc] initWithImage:[UIImage imageFromPath:TKBUNDLE(@"TapkuLibrary.bundle/Images/calendar/shadow.png")]]; deck = [[NSMutableArray alloc] initWithCapacity:3]; [self addSubview:shadow]; [self loadInitialGrids]; } return self; } - (void) drawRect:(CGRect)rect { // Drawing code //[self reload]; [[UIImage imageFromPath:TKBUNDLE(@"TapkuLibrary.bundle/Images/calendar/topbar.png")] drawAtPoint:CGPointMake(0,0)]; [self drawDayLabels:[self bounds]]; [self drawMonthLabel:[self bounds]]; } - (void) drawDayLabels:(CGRect)rect{ // Calendar starting on Monday instead of Sunday (Australia, Europe agains US american calendar) NSArray *days; CFCalendarRef currentCalendar = CFCalendarCopyCurrent(); if (CFCalendarGetFirstWeekday(currentCalendar) == 2) days = [NSArray arrayWithObjects:@"Mon",@"Tue",@"Wed",@"Thu",@"Fri",@"Sat",@"Sun",nil]; else days = [NSArray arrayWithObjects:@"Sun",@"Mon",@"Tue",@"Wed",@"Thu",@"Fri",@"Sat",nil]; CFRelease(currentCalendar); UIFont *f = [UIFont boldSystemFontOfSize:10]; [[UIColor darkGrayColor] set]; CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSaveGState(context); CGContextSetShadowWithColor(context, CGSizeMake(0.0, -1.0), 0.5, [[UIColor whiteColor]CGColor]); int i = 0; for(NSString *str in days){ [str drawInRect:CGRectMake(i * 46, 44-12, 45, 10) withFont:f lineBreakMode:UILineBreakModeWordWrap alignment:UITextAlignmentCenter]; i++; } CGContextRestoreGState(context); } - (void) drawMonthLabel:(CGRect)rect{ if(monthYear != nil){ CGRect r = CGRectInset([self bounds], 55, 8); r.size.height=42; [[UIColor colorWithRed:75.0/255.0 green:92/255.0 blue:111/255.0 alpha:1] set]; [monthYear drawInRect:r withFont:[UIFont boldSystemFontOfSize:20.0] lineBreakMode:UILineBreakModeWordWrap alignment:UITextAlignmentCenter]; } } @end |
When i try to move the TKCalendarMonthView position, the top label (monthYear gets out of position).
what i do:
inhirit from TKCalendarMonthViewController.
in viewDidLoad:
[super viewDidLoad];
CGRect frame=[self.monthView frame];
frame.origin.y=30;
[self.monthView setFrame:frame];
[self.monthView selectDate:[NSDate date]];
}
I love your library, it's amazing! saved me hours!
thanks!
The text was updated successfully, but these errors were encountered: