12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- //
- // DetailTransitSouceCell.m
- // FirstLink
- //
- // Created by jack on 15/7/21.
- // Copyright (c) 2015年 FirstLink. All rights reserved.
- //
- #import "DetailTransitSouceCell.h"
- @interface DetailTransitSouceCell ()
- @property (nonatomic, strong) UIView *middleLine;
- @end
- @implementation DetailTransitSouceCell
- @synthesize linkButton = _linkButton;
- @synthesize sourceButton = _sourceButton;
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
- {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- [self initializeLayout];
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- }
- return self;
- }
- - (void)initializeLayout{
-
- [self.contentView addSubview:self.middleLine];
- [self.contentView addSubview:self.sourceButton];
- [self.contentView addSubview:self.linkButton];
-
- [self.middleLine mas_makeConstraints:^(MASConstraintMaker *make) {
- make.center.equalTo(self.contentView);
- make.width.equalTo(@0.5);
- make.height.equalTo(@30);
- }];
-
- [self.sourceButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.bottom.equalTo(self.contentView);
- make.right.equalTo(self.middleLine.mas_left);
- }];
-
- [self.linkButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.top.bottom.equalTo(self.contentView);
- make.left.equalTo(self.middleLine.mas_right);
- }];
- }
- - (UIButton *)createButtonWithTitle:(NSString *)title imageName:(NSString *)imageName
- {
- NSString *addSpaceTitle = [NSString stringWithFormat:@" %@", title];
- UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
- [button setTitle:addSpaceTitle forState:UIControlStateNormal];
- [button setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
- [button setTitleColor:UIColorFromRGB(0x676767) forState:UIControlStateNormal];
- button.titleLabel.font = [UIFont systemFontOfSize:13];
- button.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
- button.titleLabel.numberOfLines = 1;
- return button;
- }
- - (UIButton *)linkButton
- {
- if (_linkButton == nil) {
- _linkButton = [self createButtonWithTitle:@"" imageName:@"detail_link"];
- }
- return _linkButton;
- }
- - (UIButton *)sourceButton
- {
- if (_sourceButton == nil) {
- _sourceButton = [self createButtonWithTitle:@"来源地: " imageName:@"detail_location"];
- }
- return _sourceButton;
- }
- - (UIView *)middleLine
- {
- if (_middleLine == nil){
- _middleLine = [[UIView alloc]init];
- _middleLine.backgroundColor = UIColorFromRGB(0xe5e5e5);
- }
- return _middleLine;
- }
- @end
|