Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
陈高翔
/
DreamSleep-iOS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 2c30dc06
由
cgx
编写于
2022-05-11 09:57:22 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
黑夜模式针对不好处理的UIImageView添加遮罩
1 个父辈
438fbb29
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
47 行增加
和
25 行删除
DreamSleep/DreamSleep/Basement/Category/UIView+Extras.h
DreamSleep/DreamSleep/Basement/Category/UIView+Extras.m
DreamSleep/DreamSleep/Class/HomeModule/Home/AudioDetailHeaderView.m
DreamSleep/DreamSleep/Basement/Category/UIView+Extras.h
查看文件 @
2c30dc0
...
@@ -7,6 +7,13 @@
...
@@ -7,6 +7,13 @@
#import <UIKit/UIKit.h>
#import <UIKit/UIKit.h>
// 蒙版类型
typedef
NS_ENUM
(
NSInteger
,
MaskType
)
{
MaskTypeNormal
,
// 正常,不带圆角
MaskTypeAllCorner
,
// 四周带圆角
MaskTypeCornerBottom
,
// 底部带圆角
};
NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_BEGIN
@interface
UIView
(
Extras
)
@interface
UIView
(
Extras
)
...
@@ -25,8 +32,14 @@ NS_ASSUME_NONNULL_BEGIN
...
@@ -25,8 +32,14 @@ NS_ASSUME_NONNULL_BEGIN
*/
*/
-
(
UIViewController
*
)
ds_viewController
;
-
(
UIViewController
*
)
ds_viewController
;
/// 用于调试UI
-
(
void
)
debugViewShowBorder
;
-
(
void
)
debugViewShowBorder
;
/// 设置圆角
/// @param radius radius
-
(
void
)
cornerRadius
:(
CGFloat
)
radius
;
-
(
void
)
cornerRadius
:(
CGFloat
)
radius
;
// 添加遮罩
-
(
void
)
addMaskWithType
:(
MaskType
)
type
cornerRadius
:(
CGFloat
)
cornerRadius
;
@end
@end
NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Basement/Category/UIView+Extras.m
查看文件 @
2c30dc0
...
@@ -109,4 +109,21 @@
...
@@ -109,4 +109,21 @@
self
.
layer
.
masksToBounds
=
YES
;
self
.
layer
.
masksToBounds
=
YES
;
}
}
-
(
void
)
addMaskWithType
:
(
MaskType
)
type
cornerRadius
:
(
CGFloat
)
cornerRadius
{
UIView
*
maskView
=
[[
UIView
alloc
]
initWithFrame
:
self
.
bounds
];
maskView
.
backgroundColor
=
DSBlack
;
maskView
.
alpha
=
.
3
;
[
self
addSubview
:
maskView
];
UIRectCorner
rectCorner
=
UIRectCornerAllCorners
;
if
(
type
==
MaskTypeCornerBottom
)
{
rectCorner
=
UIRectCornerBottomLeft
|
UIRectCornerBottomRight
;
}
UIBezierPath
*
path
=
[
UIBezierPath
bezierPathWithRoundedRect
:
maskView
.
bounds
byRoundingCorners
:
rectCorner
cornerRadii
:
CGSizeMake
(
cornerRadius
,
cornerRadius
)];
CAShapeLayer
*
maskLayer
=
[[
CAShapeLayer
alloc
]
init
];
maskLayer
.
frame
=
maskView
.
bounds
;
maskLayer
.
path
=
path
.
CGPath
;
maskView
.
layer
.
mask
=
maskLayer
;
}
@end
@end
DreamSleep/DreamSleep/Class/HomeModule/Home/AudioDetailHeaderView.m
查看文件 @
2c30dc0
...
@@ -9,7 +9,6 @@
...
@@ -9,7 +9,6 @@
@interface
AudioDetailHeaderView
()
@interface
AudioDetailHeaderView
()
@property
(
nonatomic
,
strong
)
UIImageView
*
bgIV
;
@property
(
nonatomic
,
strong
)
UIImageView
*
bgIV
;
@property
(
nonatomic
,
strong
)
UIView
*
maskView
;
@property
(
nonatomic
,
strong
)
UIImageView
*
audioIV
;
@property
(
nonatomic
,
strong
)
UIImageView
*
audioIV
;
@property
(
nonatomic
,
strong
)
UILabel
*
audioNameLab
;
@property
(
nonatomic
,
strong
)
UILabel
*
audioNameLab
;
@property
(
nonatomic
,
strong
)
UILabel
*
audioDescLab
;
@property
(
nonatomic
,
strong
)
UILabel
*
audioDescLab
;
...
@@ -24,21 +23,14 @@
...
@@ -24,21 +23,14 @@
self
.
clipsToBounds
=
YES
;
self
.
clipsToBounds
=
YES
;
[
self
addSubview
:
self
.
bgIV
];
[
self
addSubview
:
self
.
bgIV
];
[
self
addSubview
:
self
.
audioIV
];
[
self
addSubview
:
self
.
audioNameLab
];
[
self
addSubview
:
self
.
audioNameLab
];
if
(
courseType
==
CourseTypeSafe
)
{
if
(
courseType
==
CourseTypeSafe
)
{
[
self
addSubview
:
self
.
audioIV
];
[
self
addSubview
:
self
.
audioDescLab
];
[
self
addSubview
:
self
.
audioDescLab
];
[
self
addSubview
:
self
.
cornerView
];
[
self
addSubview
:
self
.
cornerView
];
self
.
audioDescLab
.
text
=
model
.
audio_desc
;
self
.
audioDescLab
.
text
=
model
.
audio_desc
;
}
else
{
[
self
addSubview
:
self
.
maskView
];
[
self
.
maskView
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
centerX
.
equalTo
(
self
);
make
.
width
.
height
.
equalTo
(
@118
);
make
.
top
.
equalTo
(
self
).
offset
(
118
);
}];
}
}
[
self
.
bgIV
yy_setImageWithURL
:[
NSURL
URLWithString
:
model
.
bg_url
]
placeholder
:[
UIImage
imageNamed
:
@"bannerPlaceholder"
]];
[
self
.
bgIV
yy_setImageWithURL
:[
NSURL
URLWithString
:
model
.
bg_url
]
placeholder
:[
UIImage
imageNamed
:
@"bannerPlaceholder"
]];
...
@@ -60,9 +52,9 @@
...
@@ -60,9 +52,9 @@
make
.
top
.
equalTo
(
self
).
offset
(
105
);
make
.
top
.
equalTo
(
self
).
offset
(
105
);
make
.
width
.
height
.
equalTo
(
@100
);
make
.
width
.
height
.
equalTo
(
@100
);
}
else
{
}
else
{
[
self
.
audioIV
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
centerX
.
equalTo
(
self
);
make
.
edges
.
equalTo
(
self
.
maskView
);
make
.
width
.
height
.
equalTo
(
@118
);
}]
;
make
.
top
.
equalTo
(
self
).
offset
(
118
)
;
}
}
}];
}];
[
self
.
audioNameLab
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
[
self
.
audioNameLab
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
...
@@ -86,6 +78,18 @@
...
@@ -86,6 +78,18 @@
make
.
height
.
equalTo
(
@40
);
make
.
height
.
equalTo
(
@40
);
}];
}];
}
}
// 更新布局
[
self
layoutIfNeeded
];
if
(
courseType
==
CourseTypeRelax
)
{
// 添加遮罩
if
([
self
.
dk_manager
.
themeVersion
isEqualToString
:
DKThemeVersionNight
])
{
[
self
.
bgIV
addMaskWithType
:
MaskTypeCornerBottom
cornerRadius
:
22
.
0
];
[
self
.
audioIV
addMaskWithType
:
MaskTypeAllCorner
cornerRadius
:
12
.
0
];
}
}
else
{
self
.
bgIV
.
dk_alphaPicker
=
DKAlphaPickerWithAlphas
(
1
.
0
,
.
3
,
.
5
);
self
.
audioIV
.
dk_alphaPicker
=
DKAlphaPickerWithAlphas
(
1
.
0
,
.
3
,
.
5
);
}
}
}
return
self
;
return
self
;
}
}
...
@@ -94,25 +98,13 @@
...
@@ -94,25 +98,13 @@
-
(
UIImageView
*
)
bgIV
{
-
(
UIImageView
*
)
bgIV
{
if
(
!
_bgIV
)
{
if
(
!
_bgIV
)
{
_bgIV
=
[
UIImageView
new
];
_bgIV
=
[
UIImageView
new
];
_bgIV
.
dk_alphaPicker
=
DKAlphaPickerWithAlphas
(
1
.
0
,
.
5
,
.
5
);
}
}
return
_bgIV
;
return
_bgIV
;
}
}
-
(
UIView
*
)
maskView
{
if
(
!
_maskView
)
{
_maskView
=
[
UIView
new
];
_maskView
.
backgroundColor
=
DSWhite
;
[
_maskView
cornerRadius
:
15
.
0
];
[
_maskView
addSubview
:
self
.
audioIV
];
}
return
_maskView
;
}
-
(
UIImageView
*
)
audioIV
{
-
(
UIImageView
*
)
audioIV
{
if
(
!
_audioIV
)
{
if
(
!
_audioIV
)
{
_audioIV
=
[
UIImageView
new
];
_audioIV
=
[
UIImageView
new
];
_audioIV
.
dk_alphaPicker
=
DKAlphaPickerWithAlphas
(
1
.
0
,
.
8
,
.
5
);
}
}
return
_audioIV
;
return
_audioIV
;
}
}
...
@@ -128,7 +120,7 @@
...
@@ -128,7 +120,7 @@
-
(
UILabel
*
)
audioDescLab
{
-
(
UILabel
*
)
audioDescLab
{
if
(
!
_audioDescLab
)
{
if
(
!
_audioDescLab
)
{
_audioDescLab
=
[
UILabel
labWithFont
:
SysFont
(
14
.
0
)];
_audioDescLab
=
[
UILabel
labWithFont
:
SysFont
(
14
.
0
)];
_audioDescLab
.
dk_textColorPicker
=
DKColorPickerWithColors
(
SubTitleColor
,
ColorFromHex
(
0xCAC9CD
),
DSWhite
);
_audioDescLab
.
dk_textColorPicker
=
DKColorPickerWithColors
(
SubTitleColor
,
ColorFromHex
A
(
0xFFFFFF
,
.
5
),
DSWhite
);
}
}
return
_audioDescLab
;
return
_audioDescLab
;
}
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论