123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- //
- // HSQGoodDetailBottomView.m
- // YouHuiProject
- //
- // Created by xiaoxi on 2018/1/25.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "HSQGoodDetailBottomView.h"
- #import "HSQGoodDetailModel.h"
- @interface HSQGoodDetailBottomView ()
- @end
- @implementation HSQGoodDetailBottomView
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- self.backgroundColor=[UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
- [self initSubviews];
- }
- return self;
- }
- - (void)initSubviews {
- [self addSubview:self.buyButton];
- // [self addSubview:self.commissionButton];
-
-
- self.commissionButton.frame=CGRectMake(FITSIZE(10), FITSIZE(8), (SCREEN_WIDTH-Fitsize(20))/2, FITSIZE(39));
- self.buyButton.frame=CGRectMake(FITSIZE(10), FITSIZE(8), (SCREEN_WIDTH-Fitsize(20)), FITSIZE(40));
- [_commissionButton setTitle:@"分享赚钱" forState:UIControlStateNormal];
- [_buyButton setTitle:@"领券购买" forState:UIControlStateNormal];
- // // 设置圆角
- // UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.buyButton.bounds byRoundingCorners:UIRectCornerBottomRight | UIRectCornerTopRight cornerRadii:CGSizeMake(FITSIZE(19.5), FITSIZE(19.5))];
- //
- // CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
- // maskLayer.frame = self.buyButton.bounds;
- // maskLayer.path = maskPath.CGPath;
- self.buyButton.layer.cornerRadius = Fitsize(20);
- self.buyButton.layer.masksToBounds = YES;
- // self.buyButton.layer.mask = maskLayer;
-
-
- // 设置圆角
- UIBezierPath *maskPath1 = [UIBezierPath bezierPathWithRoundedRect:self.commissionButton.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerTopLeft cornerRadii:CGSizeMake(FITSIZE(19.5), FITSIZE(19.5))];
-
- CAShapeLayer *maskLayer1 = [[CAShapeLayer alloc] init];
- maskLayer1.frame = self.commissionButton.bounds;
- maskLayer1.path = maskPath1.CGPath;
- self.commissionButton.layer.mask = maskLayer1;
- }
- - (void)setGoodModel:(HSQGoodDetailModel *)goodModel {
- _goodModel = goodModel;
-
- }
- - (void)buttonAction:(UIButton *)sender {
-
- //
- switch (sender.tag) {
- case 1:
- {
- if ([self.delegate respondsToSelector:@selector(yh_GoodDetailBottomViewClickCollectButton)]) {
- [self.delegate yh_GoodDetailBottomViewClickCollectButton];
- }
-
-
- }
- break;
- case 2:
- {
- if ([self.delegate respondsToSelector:@selector(yh_GoodDetailBottomViewClickCommissionButton)]) {
- [self.delegate yh_GoodDetailBottomViewClickCommissionButton];
- }
- }
- break;
- case 3:
- {
- if ([self.delegate respondsToSelector:@selector(yh_GoodDetailBottomViewClickBuyButton)]) {
- [self.delegate yh_GoodDetailBottomViewClickBuyButton];
- }
- }
- break;
-
- default:
- break;
- }
- }
- #pragma mark - lazy
- - (UIButton *)buyButton {
- if (!_buyButton) {
- _buyButton = [UIButton buttonWithType:UIButtonTypeCustom];
- _buyButton.backgroundColor = [UIColor YHColorWithHex:0xFA2C36];
- _buyButton.titleLabel.numberOfLines = 1;
- _buyButton.titleLabel.textAlignment = NSTextAlignmentCenter;
- _buyButton.tag = 3;
- [_buyButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
- _buyButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
- [_buyButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- [_buyButton setImage:[UIImage imageNamed:@"quan-2"] forState:UIControlStateNormal];
- [_buyButton setImageEdgeInsets:UIEdgeInsetsMake(FITSIZE(10), FITSIZE(43), FITSIZE(9), (SCREEN_WIDTH-Fitsize(20))/2-FITSIZE(67))];
- }
- return _buyButton;
- }
- - (UIButton *)commissionButton {
- if (!_commissionButton) {
- _commissionButton = [UIButton buttonWithType:UIButtonTypeCustom];
- _commissionButton.backgroundColor = [UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xFEC800] toColor:[UIColor YHColorWithHex:0xFD9D03] withWidth:(SCREEN_WIDTH-Fitsize(18))/2];
- _commissionButton.titleLabel.textAlignment = NSTextAlignmentCenter;
- _commissionButton.tag = 2;
- [_commissionButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
- _commissionButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
- [_commissionButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- [_commissionButton setImage:[UIImage imageNamed:@"fenxiang-3"] forState:UIControlStateNormal];
-
- [_commissionButton setImageEdgeInsets:UIEdgeInsetsMake(FITSIZE(10), FITSIZE(43), FITSIZE(9), (SCREEN_WIDTH-Fitsize(20))/2-FITSIZE(67))];
-
- }
- return _commissionButton;
- }
- @end
|