VLCSidebarViewCell.m 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*****************************************************************************
  2. * VLCSidebarViewCell.m
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2013-2015 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Authors: Felix Paul Kühne <fkuehne # videolan.org>
  9. *
  10. * Refer to the COPYING file of the official project for license.
  11. *****************************************************************************/
  12. #import "VLCSidebarViewCell.h"
  13. @implementation VLCSidebarViewCell
  14. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  15. if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {
  16. self.clipsToBounds = YES;
  17. self.backgroundColor = [UIColor clearColor];
  18. UIView *bgView = [[UIView alloc] init];
  19. bgView.backgroundColor = [UIColor colorWithRed:0.1137 green:0.1137 blue:0.1137 alpha:1.0f];
  20. self.selectedBackgroundView = bgView;
  21. self.imageView.contentMode = UIViewContentModeCenter;
  22. self.textLabel.font = [UIFont systemFontOfSize:([UIFont systemFontSize] * 1.2f)];
  23. self.textLabel.shadowOffset = CGSizeMake(0.0f, 1.0f);
  24. self.textLabel.shadowColor = [UIColor VLCDarkTextShadowColor];
  25. self.textLabel.textColor = [UIColor whiteColor];
  26. self.textLabel.adjustsFontSizeToFitWidth = YES;
  27. self.textLabel.minimumScaleFactor = 0.5f;
  28. self.textLabel.lineBreakMode = NSLineBreakByTruncatingTail;
  29. UIView *topLine = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [UIScreen mainScreen].bounds.size.height, 1.0f)];
  30. topLine.backgroundColor = [UIColor colorWithRed:(16.0f/255.0f) green:(16.0f/255.0f) blue:(16.0f/255.0f) alpha:1.0f];
  31. [self.textLabel.superview addSubview:topLine];
  32. UIView *bottomLine = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 50.0f, [UIScreen mainScreen].bounds.size.height, 1.0f)];
  33. bottomLine.backgroundColor = [UIColor colorWithRed:(23.0f/255.0f) green:(23.0f/255.0f) blue:(23.0f/255.0f) alpha:1.0f];
  34. [self.textLabel.superview addSubview:bottomLine];
  35. UILabel *textLabel = self.textLabel;
  36. textLabel.translatesAutoresizingMaskIntoConstraints = NO;
  37. UIImageView *imageView = self.imageView;
  38. imageView.translatesAutoresizingMaskIntoConstraints = NO;
  39. NSDictionary *dict = NSDictionaryOfVariableBindings(textLabel,imageView);
  40. [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[imageView(50)]-==8-[textLabel]|" options:0 metrics:0 views:dict]];
  41. [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[imageView(50)]|" options:0 metrics:0 views:dict]];
  42. [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[textLabel]|" options:0 metrics:0 views:dict]];
  43. }
  44. return self;
  45. }
  46. @end