I am developing an app with custom calendar.It includes day view with list of events of that day.I am getting the array of events with overlapped time slots. Now how can I display the events with proper block adjustment?
I can find the overlapped events group,But not able to set the block adjustment. Ex:- I have below events
1)From 8:00 To 12:00 event A
2)From 8:00 To 9:00 event B
3)From 9:00 To 10:00 event C
4)From 10:00 To 11:00 event D
5)From 11:00 To 12:00 event E
should be display like below picture.
This is only one type of case,I have many other type of combination.
To draw the Rect I used below method.
*- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context, 244.0/255.0, 244.0/255.0, 244.0/255.0, 1.0);
for (int i=0; i<arrayRects.count; i++)
{
if ([[arrayRects objectAtIndex:i] isKindOfClass:[NSMutableArray class]])
{
NSMutableArray *confictArray =(NSMutableArray*)[arrayRects objectAtIndex:i];
for (int j=0; j<confictArray.count; j++)
{
NSString *strRect = [confictArray objectAtIndex:j];
CGRect newRect = CGRectFromString(strRect);
newRect.size.height -=1.5;
CGContextFillRect(context, newRect);
//Draw Line on Left
{
if(i==0) {
CGContextSetRGBStrokeColor(context, 0.0, 1.0, 0.0, 1.0); // green line
} else if(i==1) {
CGContextSetRGBStrokeColor(context, 1.0, 0.0, 0.0, 1.0); // red line
} else {
CGContextSetRGBStrokeColor(context, 0.0, 0.0, 1.0, 1.0); // blue line
}
CGContextBeginPath(context);
CGContextMoveToPoint(context, newRect.origin.x , newRect.origin.y + 0.5); //start point
CGContextAddLineToPoint(context, newRect.origin.x ,newRect.origin.y + newRect.size.height - 0.5); // end path
CGContextClosePath(context); // close path
CGContextSetLineWidth(context, 5.0); // this is set from now on until you explicitly change it
CGContextStrokePath(context); //
}
}
}
else {
NSString *strRect = [arrayRects objectAtIndex:i];
CGRect newRect = CGRectFromString(strRect);
newRect.size.height -=1.5;
CGContextFillRect(context, newRect);
//Draw Line on Left
{
if(i==0) {
CGContextSetRGBStrokeColor(context, 0.0, 1.0, 0.0, 1.0); // green line
} else if(i==1) {
CGContextSetRGBStrokeColor(context, 1.0, 0.0, 0.0, 1.0); // red line
} else {
CGContextSetRGBStrokeColor(context, 0.0, 0.0, 1.0, 1.0); // blue line
}
CGContextBeginPath(context);
CGContextMoveToPoint(context, newRect.origin.x , newRect.origin.y + 0.5); //start point
CGContextAddLineToPoint(context, newRect.origin.x ,newRect.origin.y + newRect.size.height - 0.5); // end path
CGContextClosePath(context); // close path
CGContextSetLineWidth(context, 5.0); // this is set from now on until you explicitly change it
CGContextStrokePath(context); //
}
}
}*