SHARE
TWEET

Untitled

a guest Jun 19th, 2017 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)reuseIdentifier node:(GuideNode*)aNode
  2. {
  3.     if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]))
  4.     {
  5.         self.node = aNode;
  6.        
  7.         scrollView_ = [[UIScrollView alloc] initWithFrame:CGRectZero];
  8.         CGRect scrollFrame = scrollView_.frame;
  9.         scrollFrame.origin.x = 0;
  10.         scrollFrame.size.width = CGRectGetWidth(self.bounds);
  11.         switch(node.type)
  12.         {
  13.             case kGuideNodeTypeFeatured:
  14.                 scrollFrame.origin.y = 25 + kHorizontalScrollTitleSize;
  15.                 scrollFrame.size.height = 162.0;
  16.                 break;
  17.             case kGuideNodeTypeJustReleased:
  18.                 scrollFrame.origin.y = 19 + kHorizontalScrollTitleSize;
  19.                 scrollFrame.size.height = 101.0;
  20.                 break;
  21.             case kGuideNodeTypeNormal:
  22.                 scrollFrame.origin.y = 21 + kHorizontalScrollTitleSize;
  23.                 scrollFrame.size.height = 122.0;
  24.         }
  25.        
  26.         NSLog(@"scrollView.frame = %@", NSStringFromCGRect(scrollFrame));
  27.         scrollView_ = [[UIScrollView alloc] initWithFrame:scrollFrame];
  28.         scrollView_.delegate = self;
  29.         scrollView_.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
  30.         scrollView_.directionalLockEnabled = YES;
  31.         scrollView_.alwaysBounceHorizontal = YES;
  32.         scrollView_.showsHorizontalScrollIndicator = NO;       
  33.         [self addSubview:scrollView_];
  34.  
  35.         titleLine = [[UIImage imageNamed:@"AppGuideHorzLine.png"] retain];
  36.         titleString = self.node.rowTitleString;
  37.         titleFont = [[UIFont fontWithName:@"HelveticaNeue-Bold" size:14.0] retain];
  38.     }
  39.     return self;
  40. }
  41.  
  42.  
  43. - (void)drawRect:(CGRect)rect
  44. {
  45.     CGContextRef context = UIGraphicsGetCurrentContext();
  46.     CGContextClearRect(context, rect);
  47.    
  48.     [self.titleLine drawInRect:CGRectMake(0, kHorizontalScrollTitleSize / 2, self.titleLine.size.width, self.titleLine.size.height)];
  49.    
  50.     CGSize titleSize = [self.titleString sizeWithFont:titleFont constrainedToSize:CGSizeMake(CGRectGetWidth(self.bounds), 22) lineBreakMode:UILineBreakModeTailTruncation];
  51.     NSUInteger titleBackgroundWidth = 18 + titleSize.width + 18;
  52.    
  53.     [self.titleBackgroundImage drawInRect:CGRectMake(0, 0, titleBackgroundWidth, 38)];
  54.     [self.titleBackgroundEndImage drawInRect:CGRectMake(titleBackgroundWidth, 0, self.titleBackgroundEndImage.size.width, self.titleBackgroundEndImage.size.height)];
  55.  
  56.     // Draw shadow first...
  57.     [[UIColor colorWithRed:1.0/68 green:1.0/68 blue:1.0/68 alpha:1.0] set];
  58.     [self.titleString drawInRect:CGRectMake(18, 9, titleSize.width, titleSize.height) withFont:titleFont];
  59.     // ...then the text. It's just easier this way.
  60.     [[UIColor whiteColor] set];
  61.     [self.titleString drawInRect:CGRectMake(18, 8, titleSize.width, titleSize.height) withFont:titleFont];
  62. }
RAW Paste Data
Top