iOS中的自定义日历
我想在日期下的日历上添加价格值。与以下图片相同。iOS中的自定义日历
我已经尝试了许多第三方库像FSCalendar,JTCalendar,awesome-ios-ui,但并没有获得成功呢。
是否有任何其他库或解决方案。我想在日历的日期下添加价格标签。
任何帮助,将不胜感激。
我想你应该有部分的数量为2定制UICollectionView
使用,并在部分细胞的数量肯定是1 7和部分细胞的数量是42 使静态数组这就是有周天名称,比如 arrOfWeekDayName = [NSArray arrayWithObjects:@"SUN",@"MON", @"TUE", @"WED", @"THU", @"FRI", @"SAT", nil];
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView*)collectionView
{
return 2;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
if (section == 0)
{
return arrOfWeekDayName.count;
}
else{
return 42;
}
}
现在采取定制UICollectionViewCell
一个作秀周天命名 和第二的显示日期与奖品和任何你想要在你的显示图像。
例如我把两个自定义UICollectionViewCell
首先是weekCell
和第二是dateCell
weekCell
只有一个标签,这是只显示天命名 和dateCell
有三个属性lblDate
,lblPrize
,imgCell
您根据您的要求增加。
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section == 0)
{
weekCell *cell = (weekCell*)[collectionView dequeueReusableCellWithReuseIdentifier:@“weekCell” forIndexPath:indexPath];
cell.lblDay.text =[arrOfWeekDayName objectAtIndex:indexPath.row];
if (indexPath.row == 0)
{
cell.backgroundColor = [UIColor redColor];
}
else
{
cell.backgroundColor = [UIColor colorWithRed:63.0/255.0f green:65.0/255.0f blue:70.0/255.0f alpha:1.0];
}
return cell;
}
else
{
dateCell *cell = (dateCell*)[collectionView dequeueReusableCellWithReuseIdentifier:@“dateCell" forIndexPath:indexPath];
cell.lblDate.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:12];
cell.lblPrize.text= [NSString strngWithFormat:@“$5”];
cell.imgCell.image = [UIImage imageNamed:@“myImage”];
return cell;
}
}
时填写一个月的价值,你需要这42个细胞 的所有值,并根据个月奶源该小区。 奶源细胞根据天背景颜色
FirstDateOfMonth = [CommonOps firstDayOfMonth:currentdate ];
LastDateOfMonth = [CommonOps lastDayOfMonth:currentdate];
if ([self date:date isEqualOrAfter:LastDateOfMonth])
{
cell.lblDateTitle.textColor = [UIColor grayColor];
cell.backgroundColor = [UIColor colorWithRed:209/256. green:209/256. blue:209/256. alpha:.5];
cell.userInteractionEnabled = true;
}
else if ([self date: date isEqualOrBefore: FirstDateOfMonth])
{
cell.lblDateTitle.textColor = [UIColor grayColor];
cell.backgroundColor = [UIColor colorWithRed:209/256. green:209/256. blue:209/256. alpha:.5];
cell.userInteractionEnabled = true;
}
else
{
cell.backgroundColor = [UIColor colorWithRed:243/256. green:221/256. blue:159/256. alpha:.5];
cell.userInteractionEnabled = true;
if ([self date:currentdate isTheSameDayThan:date])
{
ValueToDisplayOnHeaderFirstTime = indexPath.row;
}
cell.lblDateTitle.textColor = [UIColor blackColor];
}
if (indexPath.row == 0 || indexPath.row == 7 || indexPath.row == 14 || indexPath.row == 21 || indexPath.row == 28|| indexPath.row == 35)
{
cell.backgroundColor = [UIColor colorWithRed:250/256. green:195/256. blue:181/256. alpha:.5];
cell.lblDateTitle.textColor = [UIColor redColor];
}
在此,请让我知道在评论部分
不错的解决方案,你可以详细说明解决方案..... – madhuiOS
JTAppleCalendar可以建立这个给你(不要与JTCalendar混淆),如果你的任何混淆。
似乎有据可查。 简单的设置。 如果该库无法为您创建日历,那么我会感到震惊。我在大约7分钟内完成了我的日历(完全设计)。
文档发现Here
Cocoapod链接发现Here
Github上的链接发现Here
你用哪个库? –
使用FSCalendar: https://github.com/WenchaoD/FSCalendar –
[这里有很多](https://www.cocoacontrols.com/search?q=calendar) –