1

カレンダーのカスタマイズには MBCalendarKit を使用しています。各カレンダーセルのテキストラベルに追加したい. 参考までに、github「 https://github.com/MosheBerman/MBCalendarKit 」からサンプルコードをダウンロードしてください。

編集:

複数のラベルを作成するには、for ループを使用しました。どうしたの?

NSMutableArray *dateButtons = [NSMutableArray array];
    for (NSInteger i = 1; i <= 42; i++) {
        DateButton *dateButton = [DateButton buttonWithType:UIButtonTypeCustom];
        dateButton.calendar = self.calendar;
        [dateButton addTarget:self action:@selector(_dateButtonPressed:) forControlEvents:UIControlEventTouchUpInside];

        UILabel *travelTime = [[UILabel alloc] initWithFrame:CGRectMake(3, 23, 20, 20)];
        travelTime.font=[travelTime.font fontWithSize:9];
        [travelTime setTextColor:[UIColor blueColor]];
        travelTime.text = @"9";

        UILabel *workTime = [[UILabel alloc] initWithFrame:CGRectMake(30, 23, 20, 20)];
        workTime.font=[workTime.font fontWithSize:9];
        [workTime setTextColor:[UIColor orangeColor]];
        workTime.text = @"9";

        [dateButton addSubview:travelTime];
        [dateButton addSubview:workTime];
        [dateButtons addObject:dateButton];
    }
self.dateButtons = dateButtons;
4

1 に答える 1