1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- //
- // FKBasketEmptyView.m
- // FirstLink
- //
- // Created by jack on 16/2/24.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKBasketEmptyView.h"
- @implementation FKBasketEmptyView
- - (instancetype)initWithFrame:(CGRect)frame{
- if (self = [super initWithFrame:frame]) {
-
- [self addAllSubviews];
- self.backgroundColor = UIColorFromRGB(0xf5f5f5);
- }
- return self;
- }
- - (void)addAllSubviews{
-
- UIImageView *basketImgView = ({
- UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"basket_empty"]];
- [imageView setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
- imageView;
- });
-
- UILabel *titleLabel = ({
- UILabel *label = [[UILabel alloc]init];
- label.text = @"“购物车空空如也”";
- label.font = [UIFont systemFontOfSize:15];
- label.textColor = UIColorFromRGB(0x999999);
- [label setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
- label;
- });
-
- [self addSubview:basketImgView];
- [self addSubview:titleLabel];
- [self addSubview:self.goAroundBtn];
-
- [basketImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self).offset(90);
- make.centerX.equalTo(self);
- }];
-
- [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(basketImgView.mas_bottom).offset(15);
- make.centerX.equalTo(self);
- }];
-
- [self.goAroundBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(titleLabel.mas_bottom).offset(70);
- make.centerX.equalTo(self);
- make.size.mas_equalTo(CGSizeMake(150, 35));
- }];
-
-
- }
- - (UIButton *)goAroundBtn{
- if (_goAroundBtn == nil) {
- _goAroundBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_goAroundBtn setTitle:@"去逛逛" forState:UIControlStateNormal];
- [_goAroundBtn setTitleColor:UIColorFromRGB(0x666666) forState:UIControlStateNormal];
- _goAroundBtn.titleLabel.font = [UIFont systemFontOfSize:15];
- _goAroundBtn.backgroundColor = [UIColor whiteColor];
- _goAroundBtn.layer.cornerRadius = 5;
- _goAroundBtn.layer.borderColor = [UIColorFromRGB(0xcccccc) CGColor];
- _goAroundBtn.layer.borderWidth = 0.5f;
- }
- return _goAroundBtn;
- }
- @end
|