Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #17 from Jomell/master

Tweaked OCCalendar to fit iPhone layout
  • Loading branch information...
commit af49ce330c9bc0fa1c6a74c9c607c0c6126dabea 2 parents b15b822 + dac57c3
Oliver Clark Rickard authored
6 Demo/OCCalendar/OCViewController.m
@@ -52,8 +52,10 @@ - (void)viewDidAppear:(BOOL)animated {
52 52 NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
53 53
54 54 //Here's where the magic happens
55   - calVC = [[OCCalendarViewController alloc] initAtPoint:CGPointMake(150, 50) inView:self.view arrowPosition:OCArrowPositionLeft];
  55 + calVC = [[OCCalendarViewController alloc] initAtPoint:CGPointMake(167, 50) inView:self.view arrowPosition:OCArrowPositionCentered];
56 56 calVC.delegate = self;
  57 + //Test ONLY
  58 + calVC.selectionMode = OCSelectionSingleDate;
57 59 //Now we're going to optionally set the start and end date of a pre-selected range.
58 60 //This is totally optional.
59 61 NSDateComponents *dateParts = [[NSDateComponents alloc] init];
@@ -158,7 +160,7 @@ - (void)fadeOutToolTip {
158 160 - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
159 161 CGPoint insertPoint = [touch locationInView:self.view];
160 162
161   - calVC = [[OCCalendarViewController alloc] initAtPoint:insertPoint inView:self.view arrowPosition:OCArrowPositionRight selectionMode:OCSelectionSingleDate];
  163 + calVC = [[OCCalendarViewController alloc] initAtPoint:insertPoint inView:self.view arrowPosition:OCArrowPositionCentered selectionMode:OCSelectionSingleDate];
162 164 calVC.delegate = self;
163 165 [self.view addSubview:calVC.view];
164 166
3  OCCalendarView/OCCalendarView.h
@@ -11,7 +11,8 @@
11 11 typedef enum {
12 12 OCArrowPositionLeft = -1,
13 13 OCArrowPositionCentered = 0,
14   - OCArrowPositionRight = 1
  14 + OCArrowPositionRight = 1,
  15 + OCArrowPositionNone = 99
15 16 } OCArrowPosition;
16 17
17 18
292 OCCalendarView/OCCalendarView.m
@@ -51,13 +51,15 @@ - (id)initAtPoint:(CGPoint)p withFrame:(CGRect)frame arrowPosition:(OCArrowPosit
51 51 endCellX = -1;
52 52 endCellY = -1;
53 53
54   - hDiff = 43;
  54 +
  55 + hDiff = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ? 41 : 43;
55 56 vDiff = 30;
56 57
57 58 selectionView = [[OCSelectionView alloc] initWithFrame:CGRectMake(66, 95, hDiff*7, vDiff*6)];
58 59 [self addSubview:selectionView];
59 60
60   - daysView = [[OCDaysView alloc] initWithFrame:CGRectMake(65, 98, hDiff*7, vDiff*6)];
  61 + float xpos = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ? 68 : 65;
  62 + daysView = [[OCDaysView alloc] initWithFrame:CGRectMake(xpos, 98, hDiff*7, vDiff*6)];
61 63 [daysView setYear:currentYear];
62 64 [daysView setMonth:currentMonth];
63 65 [daysView resetRows];
@@ -375,12 +377,28 @@ - (void)setEndDate:(NSDate *)eDate {
375 377 }
376 378
377 379 - (void)drawRect:(CGRect)rect
378   -{
  380 +{
  381 +
  382 + //Assumes this code works on iPhone SDK 3.2 or higher..
  383 +
  384 + if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
  385 + {
  386 + [self renderCalendarViewForPhone];
  387 +
  388 + }else{
  389 + [self renderCalendarViewForPad];
  390 + }
  391 +
  392 +}
  393 +
  394 +
  395 +-(void) renderCalendarViewForPhone
  396 +{
379 397 //// Get day titles from current Locale
380 398 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
381 399 NSArray *dayTitles = [dateFormatter shortStandaloneWeekdaySymbols];
382 400 NSArray *monthTitles = [dateFormatter standaloneMonthSymbols];
383   -
  401 +
384 402 //// General Declarations
385 403 CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
386 404 CGContextRef context = UIGraphicsGetCurrentContext();
@@ -394,8 +412,267 @@ - (void)drawRect:(CGRect)rect
394 412 UIColor* boxStroke = [UIColor colorWithRed: 0 green: 0 blue: 0 alpha: 0.59];
395 413
396 414 //// Gradient Declarations
397   - NSArray* gradient2Colors = [NSArray arrayWithObjects:
398   - (id)darkColor.CGColor,
  415 + NSArray* gradient2Colors = [NSArray arrayWithObjects:
  416 + (id)darkColor.CGColor,
  417 + (id)lightColor.CGColor, nil];
  418 + CGFloat gradient2Locations[] = {0, 1};
  419 + CGGradientRef gradient2 = CGGradientCreateWithColors(colorSpace, (CFArrayRef)gradient2Colors, gradient2Locations);
  420 +
  421 + //// Shadow Declarations
  422 + CGColorRef bigBoxInnerShadow = bigBoxInnerShadowColor.CGColor;
  423 + CGSize bigBoxInnerShadowOffset = CGSizeMake(0, 1);
  424 + CGFloat bigBoxInnerShadowBlurRadius = 1;
  425 + CGColorRef shadow = [UIColor blackColor].CGColor;
  426 + CGSize shadowOffset = CGSizeMake(-1, -0);
  427 + CGFloat shadowBlurRadius = 0;
  428 + CGColorRef shadow2 = [UIColor blackColor].CGColor;
  429 + CGSize shadow2Offset = CGSizeMake(1, 1);
  430 + CGFloat shadow2BlurRadius = 1;
  431 + CGColorRef backgroundShadow = [UIColor blackColor].CGColor;
  432 + CGSize backgroundShadowOffset = CGSizeMake(2, 3);
  433 + CGFloat backgroundShadowBlurRadius = 5;
  434 +
  435 +
  436 + //////// Draw background of popover
  437 + UIBezierPath* roundedRectanglePath = [UIBezierPath bezierPath];
  438 +
  439 +
  440 + float arrowPosX = 208;
  441 +
  442 + if(arrowPosition == OCArrowPositionLeft) {
  443 + arrowPosX = 80;
  444 + } else if(arrowPosition == OCArrowPositionRight) {
  445 + arrowPosX = 323;
  446 + }
  447 +
  448 + if([daysView addExtraRow]) {
  449 + //NSLog(@"Added extra row");
  450 +
  451 + //bottom left corner
  452 + [roundedRectanglePath moveToPoint: CGPointMake(42, 267.42)];
  453 + [roundedRectanglePath addCurveToPoint: CGPointMake(52, 278.4) controlPoint1: CGPointMake(42, 273.49) controlPoint2: CGPointMake(46.48, 278.4)];
  454 +
  455 + //bottom right corner
  456 + [roundedRectanglePath addLineToPoint: CGPointMake(348.5, 278.4)];
  457 + [roundedRectanglePath addCurveToPoint: CGPointMake(358.5, 267.42) controlPoint1: CGPointMake(354.02, 278.4) controlPoint2: CGPointMake(358.5, 273.49)];
  458 +
  459 + //top right corner
  460 + [roundedRectanglePath addLineToPoint: CGPointMake(358.5, 53.9)];
  461 + [roundedRectanglePath addCurveToPoint: CGPointMake(348.5, 43.9) controlPoint1: CGPointMake(358.02, 48.38) controlPoint2: CGPointMake(354.5, 43.9)];
  462 +
  463 + if(arrowPosition != OCArrowPositionNone)
  464 + {
  465 + [roundedRectanglePath addLineToPoint: CGPointMake(arrowPosX+13.5, 43.9)];
  466 + [roundedRectanglePath addLineToPoint: CGPointMake(arrowPosX, 31.4)];
  467 + [roundedRectanglePath addLineToPoint: CGPointMake(arrowPosX-13.5, 43.9)];
  468 + }
  469 +
  470 + //top left corner
  471 + [roundedRectanglePath addLineToPoint: CGPointMake(52, 43.9)];
  472 + [roundedRectanglePath addCurveToPoint: CGPointMake(42, 53.9) controlPoint1: CGPointMake(46.48, 43.9) controlPoint2: CGPointMake(42, 48.38)];
  473 +
  474 + [roundedRectanglePath addLineToPoint: CGPointMake(42, 267.42)];
  475 + } else {
  476 + //bottom left corner
  477 + [roundedRectanglePath moveToPoint: CGPointMake(42, 246.4)];
  478 + [roundedRectanglePath addCurveToPoint: CGPointMake(52, 256.4) controlPoint1: CGPointMake(42, 251.92) controlPoint2: CGPointMake(46.48, 256.4)];
  479 +
  480 + //bottom right corner
  481 + [roundedRectanglePath addLineToPoint: CGPointMake(348.5, 256.4)];
  482 + [roundedRectanglePath addCurveToPoint: CGPointMake(358.5, 246.4) controlPoint1: CGPointMake(354.02, 256.4) controlPoint2: CGPointMake(358.5, 251.92)];
  483 +
  484 + //top right corner
  485 + [roundedRectanglePath addLineToPoint: CGPointMake(358.5, 53.9)];
  486 + [roundedRectanglePath addCurveToPoint: CGPointMake(348.5, 43.9) controlPoint1: CGPointMake(358.5, 48.38) controlPoint2: CGPointMake(354.5, 43.9)];
  487 +
  488 + if(arrowPosition != OCArrowPositionNone)
  489 + {
  490 + [roundedRectanglePath addLineToPoint: CGPointMake(arrowPosX+13.5, 43.9)];
  491 + [roundedRectanglePath addLineToPoint: CGPointMake(arrowPosX, 31.4)];
  492 + [roundedRectanglePath addLineToPoint: CGPointMake(arrowPosX-13.5, 43.9)];
  493 + }
  494 + [roundedRectanglePath addLineToPoint: CGPointMake(52, 43.9)];
  495 + [roundedRectanglePath addCurveToPoint: CGPointMake(42, 53.9) controlPoint1: CGPointMake(46.48, 43.9) controlPoint2: CGPointMake(42, 48.38)];
  496 + [roundedRectanglePath addLineToPoint: CGPointMake(42, 246.4)];
  497 + //NSLog(@"did not add extra row");
  498 + }
  499 +
  500 + [roundedRectanglePath closePath];
  501 + CGContextSaveGState(context);
  502 + CGContextSetShadowWithColor(context, backgroundShadowOffset, backgroundShadowBlurRadius, backgroundShadow);
  503 + [backgroundLightColor setFill];
  504 + [roundedRectanglePath fill];
  505 +
  506 + ////// background Inner Shadow
  507 + CGRect roundedRectangleBorderRect = CGRectInset([roundedRectanglePath bounds], -bigBoxInnerShadowBlurRadius, -bigBoxInnerShadowBlurRadius);
  508 + roundedRectangleBorderRect = CGRectOffset(roundedRectangleBorderRect, -bigBoxInnerShadowOffset.width, -bigBoxInnerShadowOffset.height);
  509 + roundedRectangleBorderRect = CGRectInset(CGRectUnion(roundedRectangleBorderRect, [roundedRectanglePath bounds]), -1, -1);
  510 +
  511 + UIBezierPath* roundedRectangleNegativePath = [UIBezierPath bezierPathWithRect: roundedRectangleBorderRect];
  512 + [roundedRectangleNegativePath appendPath: roundedRectanglePath];
  513 + roundedRectangleNegativePath.usesEvenOddFillRule = YES;
  514 +
  515 + CGContextSaveGState(context);
  516 + {
  517 + CGFloat xOffset = bigBoxInnerShadowOffset.width + round(roundedRectangleBorderRect.size.width);
  518 + CGFloat yOffset = bigBoxInnerShadowOffset.height;
  519 + CGContextSetShadowWithColor(context,
  520 + CGSizeMake(xOffset + copysign(0.1, xOffset), yOffset + copysign(0.1, yOffset)),
  521 + bigBoxInnerShadowBlurRadius,
  522 + bigBoxInnerShadow);
  523 +
  524 + [roundedRectanglePath addClip];
  525 + CGAffineTransform transform = CGAffineTransformMakeTranslation(-round(roundedRectangleBorderRect.size.width), 0);
  526 + [roundedRectangleNegativePath applyTransform: transform];
  527 + [[UIColor grayColor] setFill];
  528 + [roundedRectangleNegativePath fill];
  529 + }
  530 + CGContextRestoreGState(context);
  531 +
  532 + CGContextRestoreGState(context);
  533 +
  534 + [boxStroke setStroke];
  535 + roundedRectanglePath.lineWidth = 0.5;
  536 + [roundedRectanglePath stroke];
  537 +
  538 +
  539 + //Dividers
  540 + float addedHeight = ([daysView addExtraRow] ? 24 : 0);
  541 + for(int i = 0; i < dayTitles.count-1; i++) {
  542 + //// divider Drawing
  543 + float xpos = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ? 99 : 96;
  544 + UIBezierPath* dividerPath = [UIBezierPath bezierPathWithRect: CGRectMake(xpos+i*hDiff, 73.5, 0.5, 168+addedHeight)];
  545 + CGContextSaveGState(context);
  546 + CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow);
  547 + [lineLightColor setFill];
  548 + [dividerPath fill];
  549 + CGContextRestoreGState(context);
  550 + }
  551 +
  552 +
  553 + //// Rounded Rectangle 2 Drawing
  554 + UIBezierPath* roundedRectangle2Path = [UIBezierPath bezierPath];
  555 + if([daysView addExtraRow]) {
  556 + //bottom left
  557 + [roundedRectangle2Path moveToPoint: CGPointMake(42, 267.42)];
  558 + [roundedRectangle2Path addCurveToPoint: CGPointMake(52, 278.4) controlPoint1: CGPointMake(42, 273.49) controlPoint2: CGPointMake(46.48, 278.4)];
  559 + //bottom right
  560 + [roundedRectangle2Path addLineToPoint: CGPointMake(348.5, 278.4)];
  561 + [roundedRectangle2Path addCurveToPoint: CGPointMake(358.5, 267.42) controlPoint1: CGPointMake(354.02, 278.4) controlPoint2: CGPointMake(358.5, 273.49)];
  562 + //top right
  563 + [roundedRectangle2Path addLineToPoint: CGPointMake(358.5, 53.9)];
  564 + [roundedRectangle2Path addCurveToPoint: CGPointMake(348.5, 43.9) controlPoint1: CGPointMake(358.02, 48.38) controlPoint2: CGPointMake(354.5, 43.9)];
  565 +
  566 + if(arrowPosition != OCArrowPositionNone)
  567 + {
  568 + [roundedRectangle2Path addLineToPoint: CGPointMake(arrowPosX+13.5, 43.9)];
  569 + [roundedRectangle2Path addLineToPoint: CGPointMake(arrowPosX, 31.4)];
  570 + [roundedRectangle2Path addLineToPoint: CGPointMake(arrowPosX-13.5, 43.9)];
  571 + }
  572 + //top left
  573 + [roundedRectangle2Path addLineToPoint: CGPointMake(52, 43.9)];
  574 + [roundedRectangle2Path addCurveToPoint: CGPointMake(42, 53.9) controlPoint1: CGPointMake(46.48, 43.9) controlPoint2: CGPointMake(42, 48.38)];
  575 + [roundedRectangle2Path addLineToPoint: CGPointMake(42, 267.42)];
  576 + } else {
  577 + //bottom left
  578 + [roundedRectangle2Path moveToPoint: CGPointMake(42, 246.4)];
  579 + [roundedRectangle2Path addCurveToPoint: CGPointMake(52, 256.4) controlPoint1: CGPointMake(42, 251.92) controlPoint2: CGPointMake(46.48, 256.4)];
  580 + //bottom right
  581 + [roundedRectangle2Path addLineToPoint: CGPointMake(348.5, 256.4)];
  582 + [roundedRectangle2Path addCurveToPoint: CGPointMake(358.5, 246.4) controlPoint1: CGPointMake(354.02, 256.4) controlPoint2: CGPointMake(358.5, 251.92)];
  583 + //top right
  584 + [roundedRectangle2Path addLineToPoint: CGPointMake(358.5, 53.9)];
  585 + [roundedRectangle2Path addCurveToPoint: CGPointMake(348.5, 43.9) controlPoint1: CGPointMake(358.5, 48.38) controlPoint2: CGPointMake(354.02, 43.9)];
  586 +
  587 + if(arrowPosition != OCArrowPositionNone)
  588 + {
  589 + [roundedRectangle2Path addLineToPoint: CGPointMake(arrowPosX+13.5, 43.9)];
  590 + [roundedRectangle2Path addLineToPoint: CGPointMake(arrowPosX, 31.4)];
  591 + [roundedRectangle2Path addLineToPoint: CGPointMake(arrowPosX-13.5, 43.9)];
  592 + }
  593 + //top left
  594 + [roundedRectangle2Path addLineToPoint: CGPointMake(52, 43.9)];
  595 + [roundedRectangle2Path addCurveToPoint: CGPointMake(42, 53.9) controlPoint1: CGPointMake(46.48, 43.9) controlPoint2: CGPointMake(42, 48.38)];
  596 + [roundedRectangle2Path addLineToPoint: CGPointMake(42, 246.4)];
  597 + }
  598 + [roundedRectangle2Path closePath];
  599 + CGContextSaveGState(context);
  600 + [roundedRectangle2Path addClip];
  601 + float endPoint = ([daysView addExtraRow] ? 278.4 : 256.4);
  602 + CGContextDrawLinearGradient(context, gradient2, CGPointMake(206.75, endPoint), CGPointMake(206.75, 31.4), 0);
  603 + CGContextRestoreGState(context);
  604 +
  605 + for(int i = 0; i < dayTitles.count; i++) {
  606 + //// dayHeader Drawing
  607 + CGContextSaveGState(context);
  608 + CGContextSetShadowWithColor(context, shadow2Offset, shadow2BlurRadius, shadow2);
  609 + CGRect dayHeaderFrame = CGRectMake(63+i*hDiff, 75, 30, 14);
  610 + [[UIColor whiteColor] setFill];
  611 + [((NSString *)[dayTitles objectAtIndex:i]) drawInRect: dayHeaderFrame withFont: [UIFont fontWithName: @"Helvetica" size: 12] lineBreakMode: UILineBreakModeWordWrap alignment: UITextAlignmentCenter];
  612 + CGContextRestoreGState(context);
  613 + }
  614 +
  615 + int month = currentMonth;
  616 + int year = currentYear;
  617 +
  618 + NSString *monthTitle = [NSString stringWithFormat:@"%@ %d", [monthTitles objectAtIndex:(month - 1)], year];
  619 +
  620 + //// Month Header Drawing
  621 + CGContextSaveGState(context);
  622 + CGContextSetShadowWithColor(context, shadow2Offset, shadow2BlurRadius, shadow2);
  623 + CGRect textFrame = CGRectMake(94, 53, 220, 18);
  624 + [[UIColor whiteColor] setFill];
  625 + [monthTitle drawInRect: textFrame withFont: [UIFont fontWithName: @"Helvetica" size: 12] lineBreakMode: UILineBreakModeWordWrap alignment: UITextAlignmentCenter];
  626 + CGContextRestoreGState(context);
  627 +
  628 + //// backArrow Drawing
  629 + UIBezierPath* backArrowPath = [UIBezierPath bezierPath];
  630 + [backArrowPath moveToPoint: CGPointMake(66, 58.5)];
  631 + [backArrowPath addLineToPoint: CGPointMake(60, 62.5)];
  632 + [backArrowPath addCurveToPoint: CGPointMake(66, 65.5) controlPoint1: CGPointMake(60, 62.5) controlPoint2: CGPointMake(66, 65.43)];
  633 + [backArrowPath addCurveToPoint: CGPointMake(66, 58.5) controlPoint1: CGPointMake(66, 65.57) controlPoint2: CGPointMake(66, 58.5)];
  634 + [backArrowPath closePath];
  635 + [[UIColor whiteColor] setFill];
  636 + [backArrowPath fill];
  637 +
  638 + //// forwardArrow Drawing
  639 + UIBezierPath* forwardArrowPath = [UIBezierPath bezierPath];
  640 + [forwardArrowPath moveToPoint: CGPointMake(336.5, 58.5)];
  641 + [forwardArrowPath addLineToPoint: CGPointMake(342.5, 62)];
  642 + [forwardArrowPath addCurveToPoint: CGPointMake(336.5, 65.5) controlPoint1: CGPointMake(342.5, 62) controlPoint2: CGPointMake(336.5, 65.43)];
  643 + [forwardArrowPath addCurveToPoint: CGPointMake(336.5, 58.5) controlPoint1: CGPointMake(336.5, 65.57) controlPoint2: CGPointMake(336.5, 58.5)];
  644 + [forwardArrowPath closePath];
  645 + [[UIColor whiteColor] setFill];
  646 + [forwardArrowPath fill];
  647 +
  648 + //// Cleanup
  649 + CGGradientRelease(gradient2);
  650 + CGColorSpaceRelease(colorSpace);
  651 +
  652 +}
  653 +
  654 +-(void) renderCalendarViewForPad
  655 +{
  656 + //// Get day titles from current Locale
  657 + NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  658 + NSArray *dayTitles = [dateFormatter shortStandaloneWeekdaySymbols];
  659 + NSArray *monthTitles = [dateFormatter standaloneMonthSymbols];
  660 +
  661 + //// General Declarations
  662 + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
  663 + CGContextRef context = UIGraphicsGetCurrentContext();
  664 +
  665 + //// Color Declarations
  666 + UIColor* bigBoxInnerShadowColor = [UIColor colorWithRed: 1 green: 1 blue: 1 alpha: 0.56];
  667 + UIColor* backgroundLightColor = [UIColor colorWithWhite:0.2 alpha: 1];
  668 + UIColor* lineLightColor = [UIColor colorWithRed: 1 green: 1 blue: 1 alpha: 0.27];
  669 + UIColor* lightColor = [UIColor colorWithRed: 0 green: 0 blue: 0 alpha: 0.15];
  670 + UIColor* darkColor = [UIColor colorWithRed: 0 green: 0 blue: 0 alpha: 0.72];
  671 + UIColor* boxStroke = [UIColor colorWithRed: 0 green: 0 blue: 0 alpha: 0.59];
  672 +
  673 + //// Gradient Declarations
  674 + NSArray* gradient2Colors = [NSArray arrayWithObjects:
  675 + (id)darkColor.CGColor,
399 676 (id)lightColor.CGColor, nil];
400 677 CGFloat gradient2Locations[] = {0, 1};
401 678 CGGradientRef gradient2 = CGGradientCreateWithColors(colorSpace, (CFArrayRef)gradient2Colors, gradient2Locations);
@@ -590,8 +867,11 @@ - (void)drawRect:(CGRect)rect
590 867 //// Cleanup
591 868 CGGradientRelease(gradient2);
592 869 CGColorSpaceRelease(colorSpace);
  870 +
  871 +
593 872 }
594 873
  874 +
595 875 - (void)dealloc {
596 876
597 877 [selectionView release];
2  OCCalendarView/OCDaysView.m
@@ -21,7 +21,7 @@ - (id)initWithFrame:(CGRect)frame
21 21 endCellX = 3;
22 22 endCellY = 0;
23 23
24   - hDiff = 43;
  24 + hDiff = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ? 41 : 43;
25 25 vDiff = 30;
26 26
27 27 self.backgroundColor = [UIColor clearColor];
5 OCCalendarView/OCSelectionView.m
@@ -25,7 +25,7 @@ - (id)initWithFrame:(CGRect)frame
25 25 endCellX = -1;
26 26 endCellY = -1;
27 27
28   - hDiff = 43;
  28 + hDiff = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ? 41 : 43;
29 29 vDiff = 30;
30 30
31 31 self.userInteractionEnabled = YES;
@@ -93,7 +93,8 @@ - (void)drawRect:(CGRect)rect
93 93 cornerRadius = 10.0;
94 94 }
95 95 //// selectedRect Drawing
96   - UIBezierPath* selectedRectPath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(MIN(thisRowStartCell, thisRowEndCell)*hDiff, i*vDiff, (ABS(thisRowEndCell-thisRowStartCell))*hDiff+20, 21) cornerRadius: cornerRadius];
  96 + float width_offset= UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ? 25 : 20; //device specific width offset i.e., iPhone vs iPad
  97 + UIBezierPath* selectedRectPath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(MIN(thisRowStartCell, thisRowEndCell)*hDiff, i*vDiff, (ABS(thisRowEndCell-thisRowStartCell))*hDiff+width_offset, 21) cornerRadius: cornerRadius];
97 98 CGContextSaveGState(context);
98 99 [selectedRectPath addClip];
99 100 CGContextDrawLinearGradient(context, gradient3, CGPointMake((MIN(thisRowStartCell, thisRowEndCell)+.5)*hDiff, (i+1)*vDiff), CGPointMake((MIN(thisRowStartCell, thisRowEndCell)+.5)*hDiff, i*vDiff), 0);

0 comments on commit af49ce3

Please sign in to comment.
Something went wrong with that request. Please try again.