Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)reuseIdentifier node:(GuideNode*)aNode
- {
- if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]))
- {
- self.node = aNode;
- scrollView_ = [[UIScrollView alloc] initWithFrame:CGRectZero];
- CGRect scrollFrame = scrollView_.frame;
- scrollFrame.origin.x = 0;
- scrollFrame.size.width = CGRectGetWidth(self.bounds);
- switch(node.type)
- {
- case kGuideNodeTypeFeatured:
- scrollFrame.origin.y = 25 + kHorizontalScrollTitleSize;
- scrollFrame.size.height = 162.0;
- break;
- case kGuideNodeTypeJustReleased:
- scrollFrame.origin.y = 19 + kHorizontalScrollTitleSize;
- scrollFrame.size.height = 101.0;
- break;
- case kGuideNodeTypeNormal:
- scrollFrame.origin.y = 21 + kHorizontalScrollTitleSize;
- scrollFrame.size.height = 122.0;
- }
- NSLog(@"scrollView.frame = %@", NSStringFromCGRect(scrollFrame));
- scrollView_ = [[UIScrollView alloc] initWithFrame:scrollFrame];
- scrollView_.delegate = self;
- scrollView_.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- scrollView_.directionalLockEnabled = YES;
- scrollView_.alwaysBounceHorizontal = YES;
- scrollView_.showsHorizontalScrollIndicator = NO;
- [self addSubview:scrollView_];
- titleLine = [[UIImage imageNamed:@"AppGuideHorzLine.png"] retain];
- titleString = self.node.rowTitleString;
- titleFont = [[UIFont fontWithName:@"HelveticaNeue-Bold" size:14.0] retain];
- }
- return self;
- }
- - (void)drawRect:(CGRect)rect
- {
- CGContextRef context = UIGraphicsGetCurrentContext();
- CGContextClearRect(context, rect);
- [self.titleLine drawInRect:CGRectMake(0, kHorizontalScrollTitleSize / 2, self.titleLine.size.width, self.titleLine.size.height)];
- CGSize titleSize = [self.titleString sizeWithFont:titleFont constrainedToSize:CGSizeMake(CGRectGetWidth(self.bounds), 22) lineBreakMode:UILineBreakModeTailTruncation];
- NSUInteger titleBackgroundWidth = 18 + titleSize.width + 18;
- [self.titleBackgroundImage drawInRect:CGRectMake(0, 0, titleBackgroundWidth, 38)];
- [self.titleBackgroundEndImage drawInRect:CGRectMake(titleBackgroundWidth, 0, self.titleBackgroundEndImage.size.width, self.titleBackgroundEndImage.size.height)];
- // Draw shadow first...
- [[UIColor colorWithRed:1.0/68 green:1.0/68 blue:1.0/68 alpha:1.0] set];
- [self.titleString drawInRect:CGRectMake(18, 9, titleSize.width, titleSize.height) withFont:titleFont];
- // ...then the text. It's just easier this way.
- [[UIColor whiteColor] set];
- [self.titleString drawInRect:CGRectMake(18, 8, titleSize.width, titleSize.height) withFont:titleFont];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement