Commit 5dcda14a cgx

优化首页哄睡、呼吸法等

1 个父辈 d87d2176
......@@ -11,9 +11,9 @@
#import "BreatheController.h"
@interface DsMiddleView ()
@property (nonatomic, strong) UIButton *unityBtn;
@property (nonatomic, strong) UIButton *balanceBtn;
@property (nonatomic, strong) UIButton *comfortableBtn;
@property (nonatomic, strong) UIImageView *unityIV;
@property (nonatomic, strong) UIImageView *balanceIV;
@property (nonatomic, strong) UIImageView *comfortableIV;
@property (nonatomic, strong) NSArray *middleImgs;
@end
......@@ -23,25 +23,25 @@
[super layoutSubviews];
CGFloat width = (kScreenWidth - 2*15 - 14)/2;
[self.unityBtn mas_makeConstraints:^(MASConstraintMaker *make) {
[self.unityIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self);
make.leftMargin.equalTo(self).offset(15);
make.width.equalTo(@(width));
make.height.equalTo(@(133*width/165.0));
}];
[self.balanceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.unityBtn);
[self.balanceIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.unityIV);
make.rightMargin.equalTo(self).offset(-15);
make.width.equalTo(self.unityBtn);
make.width.equalTo(self.unityIV);
make.height.equalTo(@(62*width/166.0));
}];
[self.comfortableBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.equalTo(self.balanceBtn);
make.height.equalTo(self.balanceBtn);
make.rightMargin.equalTo(self.balanceBtn);
make.bottom.equalTo(self.unityBtn);
[self.comfortableIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.equalTo(self.balanceIV);
make.height.equalTo(self.balanceIV);
make.rightMargin.equalTo(self.balanceIV);
make.bottom.equalTo(self.unityIV);
}];
self.height = self.unityBtn.height;
self.height = self.unityIV.height;
}
- (instancetype)initWithFrame:(CGRect)frame {
......@@ -49,24 +49,27 @@
self.middleImgs = [HeaderDataModel getDsMiddleImages];
for (int i = 0; i < self.middleImgs.count; i++) {
UIButton *btn = [UIButton new];
[btn setBackgroundImage:[UIImage imageNamed:self.middleImgs[i]] forState:UIControlStateNormal];
btn.tag = i;
[btn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:btn];
UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:self.middleImgs[i]]];
[iv dk_setAlphaPicker:DKAlphaPickerWithAlphas(1.0, .5, .5)];
iv.tag = i;
iv.userInteractionEnabled = YES;
UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
[iv addGestureRecognizer:tapGR];
[self addSubview:iv];
if (i == 0) {
self.unityBtn = btn;
self.unityIV = iv;
} else if (i == 1) {
self.balanceBtn = btn;
self.balanceIV = iv;
} else {
self.comfortableBtn = btn;
self.comfortableIV = iv;
}
}
}
return self;
}
- (void)btnAction:(UIButton *)sender {
- (void)tapAction:(UITapGestureRecognizer *)tapper {
UIView *sender = tapper.view;
// 判断是否登录成功
if ([LoginUtils getUserLoginData]) {
if (sender.tag == 0) {
......
......@@ -17,6 +17,7 @@
// 轮播图
@property (nonatomic, strong) CWCarousel *barnnerView;
@property (nonatomic, strong) NSArray *bannerDatas;
// 哄睡、呼吸法区域
@property (nonatomic, strong) DsMiddleView *dsMiddleView;
@end
......@@ -117,14 +118,10 @@
// 自定义pagecontrol
CGFloat width = [CWPageControl widthFromNumber:self.bannerDatas.count];
CWPageControl *pageC = [[CWPageControl alloc] initWithFrame:CGRectMake(0, 0, width, 20)];
pageC.translatesAutoresizingMaskIntoConstraints = NO;
[[pageC.widthAnchor constraintEqualToConstant:width] setActive:YES];
_barnnerView = [[CWCarousel alloc] initWithFrame:CGRectZero
delegate:self
datasource:self
flowLayout:flowLayout];
_barnnerView.translatesAutoresizingMaskIntoConstraints = NO;
_barnnerView.isAuto = YES;
_barnnerView.endless = YES;
_barnnerView.autoTimInterval = 3;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!