Commit 9b7d1d72 authored by jz's avatar jz

update

parent 4d540877
//
// FixHorzontalLayoutButton.swift
// Gengmei
//
// Created by wangyang on 16/5/16.
// Copyright © 2016年 更美互动信息科技有限公司. All rights reserved.
//
import UIKit
//import GMBaseSwift
/**
* @author licong, 15-09-27 17:09:12
*
* Button同时存在图片和文字时候的排列样式
*
* @since 5.2.0
*/
@objc public enum ImageTitleType: Int {
case imageLeftTitleRight = 0
case imageRightTitleLeft = 1
case imageTopTitleBottom = 2
case imageBottomTitleTop = 3
func isHorizontalLayout() -> Bool {
if self.rawValue < 2 {
return true
} else {
return false
}
}
}
/// 注意:不能在tableView或者collectionView中使用
@objcMembers
public class AllLayoutButton: GMButton {
public var type = ImageTitleType.imageRightTitleLeft
public var space: CGFloat = 5.0
public var margin = UIEdgeInsets.zero
public convenience init(image: UIImage?, title: String?, titleColor: UIColor?, font: UIFont?) {
self.init()
setTitle(title, for: .normal)
setImage(image, for: .normal)
setTitleColor(titleColor, for: .normal)
if font != nil {
titleLabel?.font = font
}
}
override public func layoutSubviews() {
super.layoutSubviews()
self.titleEdgeInsets = UIEdgeInsets.zero
self.imageEdgeInsets = UIEdgeInsets.zero
/* 以水平模式来讲解。把titleLabel、image和space看作一个整体square,这个整体的大小正好可以用 intrinsicContentSize 来表示。
centerX是button的中心点
|----------------------------------|
| |
| |--------------| |-------| |
| | Label | s| Image | |
| | | | | |
| |--------------| |-------| |
| |
|----------------------------------|
|centerX
| squareSize |
*/
let buttonWidth = bounds.size.width
let buttonHeight = bounds.size.height
let centerX = buttonWidth / 2.0
let centerY = buttonHeight / 2.0
let squareSize = intrinsicContentSize
let squareLeft = floor(centerX - squareSize.width / 2)
let squareRight = floor(centerX + squareSize.width / 2)
let spuareTop = floor(centerY - squareSize.height / 2)
let spuareBottom = floor(centerY + squareSize.height / 2)
switch type {
case .imageLeftTitleRight:
imageView?.left = squareLeft + margin.left
titleLabel?.right = squareRight - margin.right
case .imageRightTitleLeft:
titleLabel?.left = squareLeft + margin.left
imageView?.right = squareRight - margin.right
case .imageTopTitleBottom:
imageView?.top = spuareTop + margin.top
imageView?.centerX = centerX
titleLabel?.bottom = spuareBottom - margin.bottom
titleLabel?.width = squareSize.width
titleLabel?.centerX = centerX
case .imageBottomTitleTop:
titleLabel?.top = spuareTop + margin.top
titleLabel?.width = squareSize.width
titleLabel?.centerX = centerX
imageView?.bottom = spuareBottom - margin.bottom
imageView?.centerX = centerX
}
}
override public var intrinsicContentSize: CGSize {
var size = super.intrinsicContentSize
size.width += margin.left + margin.right
size.height += margin.top + margin.bottom
let labelHeight = titleLabel?.intrinsicContentSize.height
let labelWidth = titleLabel?.intrinsicContentSize.width
let imageViewHeight = imageView?.intrinsicContentSize.height
let imageViewWidth = imageView?.intrinsicContentSize.width
if type.isHorizontalLayout() {
size.width += space
} else {
//竖直image和title竖直排列
size.height = labelHeight! + imageViewHeight! + space
if labelWidth != nil && imageViewWidth != nil && labelWidth! > imageViewWidth! {
size.width = labelWidth!
} else {
size.width = imageViewWidth!
}
}
return size
}
// 强制刷新,否则 layout会不正确
override public func setTitle(_ title: String?, for state: UIControl.State) {
super.setTitle(title, for: state)
self.layoutIfNeeded()
}
// 强制刷新,否则 layout会不正确
override public func setImage(_ image: UIImage?, for state: UIControl.State) {
super.setImage(image, for: state)
self.layoutIfNeeded()
}
}
//
// GMAdLabel.swift
// Gengmei
//
// Created by Terminator on 2016/12/22.
// Copyright © 2016年 更美互动信息科技有限公司. All rights reserved.
//
import UIKit
//import GMBaseSwift
@objcMembers
public class GMAdLabel: GMLabel {
var ADText = "" {
didSet {
adLabel.text = ADText
}
}
var adLabel = GMLabel()
var isSHowAD = false {
didSet {
if isSHowAD {
adLabel.isHidden = false
} else {
adLabel.isHidden = true
}
}
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
public var adLabelTop = 0 {
didSet {
adLabel.snp.remakeConstraints { (make) in
make.left.equalTo(0)
make.top.equalTo(adLabelTop)
}
}
}
override init(frame: CGRect) {
super.init(frame: frame)
adLabel.isHidden = true
adLabel.layer.cornerRadius = 3
adLabel.clipsToBounds = true
adLabel.layer.borderColor = UIColor.secondaryVisual.cgColor
adLabel.layer.borderWidth = Constant.onePixel
adLabel.backgroundColor = UIColor.white
adLabel.font = UIFont.gmFont(10)
adLabel.textColor = UIColor.secondaryVisual
// 设计图是(2, 5, 2, 5),但是由于字体本身上下有空白,所以改为
adLabel.paddingEdge = UIEdgeInsets(top: 1, left: 5, bottom: 1, right: 5)
adLabel.textAlignment = .center
addSubview(adLabel)
}
}
//
// GMInstallmentView.h
// Gengmei
//
// Created by Terminator on 16/10/23.
// Copyright © 2016年 更美互动信息科技有限公司. All rights reserved.
//
#import "GMView.h"
#import "GMImageView.h"
#import "GMHighlightLabel.h"
@interface GMInstallmentView : GMView
@property (nonatomic, strong) GMHighlightLabel *promoteLabel;
@property (nonatomic, strong) GMImageView *icon;
@end
//
// GMInstallmentView.m
// Gengmei
//
// Created by Terminator on 16/10/23.
// Copyright © 2016年 更美互动信息科技有限公司. All rights reserved.
//
#import "GMInstallmentView.h"
#import <GMKit/GMFont.h>
#import <GMKit/UIColor+GMTheme.h>
#import <GMKit/UIView+LineWithAutolayout.h>
@interface GMInstallmentView()
@property (nonatomic, strong) GMView *installView;
@end
@implementation GMInstallmentView
- (void)setup {
[super setup];
_installView = [[GMView alloc] init];
[_installView addTopLineWithLeft:15 right:-15];
[self addSubview:_installView];
[_installView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(0);
make.right.mas_equalTo(0);
make.top.mas_equalTo(0);
make.height.mas_equalTo(45);
}];
_icon = [[GMImageView alloc] init];
_icon.image = [UIImage imageNamed:@"installment_icon"];
[_installView addSubview:_icon];
[_icon mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(15);
make.centerY.mas_equalTo(0);
}];
_promoteLabel = [[GMHighlightLabel alloc] init];
[_promoteLabel setContentHuggingPriority:100 forAxis:UILayoutConstraintAxisHorizontal];
[_promoteLabel setContentCompressionResistancePriority:1000 forAxis:UILayoutConstraintAxisHorizontal];
_promoteLabel.hightlightColor = UIColor.secondaryVisual;
_promoteLabel.normalColor = UIColor.bodyText ;
_promoteLabel.textColor = UIColor.bodyText;
_promoteLabel.font = [UIFont gmFont:11];
_promoteLabel.hightlightFont = [UIFont gmBoldFont:11];
[_installView addSubview:_promoteLabel];
[_promoteLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(_icon.mas_right).offset(10);
make.right.mas_lessThanOrEqualTo(-15);
make.centerY.equalTo(_icon.mas_centerY);
}];
}
@end
//
// GMInsuranceView.h
// Gengmei
//
// Created by 翟国钧 on 2017/2/13.
// Copyright © 2017年 更美互动信息科技有限公司. All rights reserved.
//
#import "GMView.h"
#import "GMLabel.h"
@interface GMInsuranceView : GMView
@property (nonatomic, strong) GMLabel *insuranceLabel;
@end
//
// GMInsuranceView.m
// Gengmei
//
// Created by 翟国钧 on 2017/2/13.
// Copyright © 2017年 更美互动信息科技有限公司. All rights reserved.
//
#import "GMInsuranceView.h"
#import "GMImageView.h"
#import <GMKit/UIColor+GMTheme.h>
#import <GMKit/UIView+LineWithAutolayout.h>
@interface GMInsuranceView()
@property (nonatomic, strong) GMView *installView;
@property (nonatomic, strong) GMImageView *icon;
@end
@implementation GMInsuranceView
- (void)setup {
[super setup];
_installView = [[GMView alloc] init];
[_installView addTopLineWithLeft:15 right:-15];
[self addSubview:_installView];
[_installView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(0);
make.right.mas_equalTo(0);
make.top.mas_equalTo(0);
make.height.mas_equalTo(45);
}];
_icon = [[GMImageView alloc] init];
_icon.image = [UIImage imageNamed:@"welfare_insurance"];
[_installView addSubview:_icon];
[_icon mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(15);
make.centerY.mas_equalTo(0);
}];
_insuranceLabel = [GMLabel labelWithTextColor:UIColor.bodyText fontSize:11];
[_installView addSubview:_insuranceLabel];
[_insuranceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(_icon.mas_right).offset(10);
make.centerY.equalTo(_icon.mas_centerY);
}];
}
@end
//
// GMLiveWelfareView.h
// Gengmei
//
// Created by 汪俊 on 2017/3/30.
// Copyright © 2017年 更美互动信息科技有限公司. All rights reserved.
//
#import "GMImageView.h"
#import "GMInstallmentView.h"
#import "GMInsuranceView.h"
//#import "Gengmei-Swift.h"
@class AllLayoutButton;
@class GMLiveWelfareView;
@class GMAdLabel;
@protocol GMLiveWelfareViewDelegate <NSObject>
- (void)didSelectedWelfareView:(GMLiveWelfareView *)welFareView;
- (void)didClickedHospitalDetailButton:(AllLayoutButton *)button;
@end
/**
直播和回放页面的美购
*/
@interface GMLiveWelfareView : GMView
@property (nonatomic , strong) GMView *welfareContainer;
/** @brief 美购大图片 */
@property (nonatomic , strong) GMImageView *bigIconImage;
/** @brief 预付价 */
@property (nonatomic , strong) GMImageView *yufuImage;
/** @brief 已售完 */
@property (nonatomic , strong) GMImageView *sallOutImage;
/** @brief 美购标题 */
@property (nonatomic , strong) GMLabel *welfareTitle;
/** @brief 美购简介 */
@property (nonatomic , strong) GMAdLabel *welfareContent;
/** @brief 更美价 */
@property (nonatomic , strong) GMLabel *gengmeiPrice;
/** @brief 市场价 */
@property (nonatomic , strong) GMLabel *marketPrice;
/** @brief 删除线 */
@property (nonatomic , strong) GMLabel *deleteLabel;
/** @brief 人民币(元/元起) */
@property (nonatomic , strong) GMLabel *yuanLabel;
/** @brief 预付款标签 */
@property (nonatomic , strong) GMLabel *yufuLabel;
/** @brief 申请数 */
@property (nonatomic , strong) GMLabel *applyNumber;
/** @brief 剩余多少个*/
@property (nonatomic , strong) GMLabel *surplusLabel;
/** @brief 城市 */
@property (nonatomic , strong) GMLabel *cityLabel;
/** @brief 医生 */
@property (nonatomic , strong) GMLabel *doctorLabel;
/** @brief 机构 */
@property (nonatomic , strong) GMLabel *hospitalLabel;
/**状态栏背景*/
@property (nonatomic, strong) GMView *statusBG;
/** @brief */
@property (nonatomic , strong) UIView *surplusBG;
/** @brief 秒杀价图片*/
@property (nonatomic , strong) GMImageView *seckillIcon;
/** seckill是否隐藏*/
@property (nonatomic, assign) BOOL isSeckillHidden;
/**
展示推广label
@author wangjun 16-08-01 in 6.3.0
*/
@property (nonatomic, assign) BOOL showPromotion;
/**
分期提示
*/
//@property (nonatomic, strong) GMInstallmentView *installmentView;
/**
保险提示
*/
//@property (nonatomic, strong) GMInsuranceView *insuranceView;
/**
是否展示推分期
*/
//@property (nonatomic, assign) BOOL showInstallment;
/**
是否展示保险
*/
//@property (nonatomic, assign) BOOL showInsurance;
@property (nonatomic , strong) UIImageView *hospitalBg;
@property (nonatomic, weak) id<GMLiveWelfareViewDelegate> delegate;
- (void)show;
- (void)hide;
@end
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment