I am using this calendar for my application.

Question : how to resize the frame of this calendar. I tried one by doing this

calendar            =   [[TKCalendarMonthView alloc] init];
calendar.delegate   =   self;
calendar.frame      =   CGRectMake(0, 0, 200, calendar.frame.size.height);

However it is still shown as width of 360

Does anybody have any clues how to do this

有帮助吗?

解决方案

You won't be able to change the width of the month view (tiles) without making a lot of changes to TKCalendarMonthViewController. For example, the width of each individual tile/day is set to 46 in the -(id)initWithSundayAsFirst method.

int i = 0;
for(NSString *s in ar){
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(46 * i, 29, 46, 15)];
    [self addSubview:label];
    label.text = s;
    label.textAlignment = UITextAlignmentCenter;
    label.shadowColor = [UIColor whiteColor];
    label.shadowOffset = CGSizeMake(0, 1);
    label.font = [UIFont systemFontOfSize:11];
    label.backgroundColor = [UIColor clearColor];
    label.textColor = [UIColor colorWithRed:59/255. green:73/255. blue:88/255. alpha:1];
    i++;
}

You'll notice that images are used to for the backgrounds of individual tiles in many of the methods, so you would need to create images suitable for your custom width. For example -(void)reactToTouch:down contains:

self.selectedImageView.image = [UIImage imageWithContentsOfFile:TKBUNDLE(@"TapkuLibrary.bundle/Images/calendar/Month Calendar Date Tile Selected.png")];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top