Commit 44986f42 authored by pete谢兆麟's avatar pete谢兆麟

扩展了屏幕适配属性

parent dbff09e9
......@@ -24,7 +24,7 @@ class YHAdopterCardExampleView: UIView {
data = ["service_adopter_example_china"]
centerView.snp.remakeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(CGFloat(691).scaleSizeFrom375px(size: 691))
make.height.equalTo(691.fix)
}
}
if type == .resident {
......@@ -32,7 +32,7 @@ class YHAdopterCardExampleView: UIView {
data = ["service_adopter_example_resident"]
centerView.snp.remakeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(CGFloat(667).scaleSizeFrom375px(size: 667))
make.height.equalTo(667.fix)
}
}
if type == .birth {
......@@ -40,7 +40,7 @@ class YHAdopterCardExampleView: UIView {
data = ["service_adopter_example_birth"]
centerView.snp.remakeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(CGFloat(453).scaleSizeFrom375px(size: 453))
make.height.equalTo(453.fix)
}
}
if type == .marry {
......@@ -48,7 +48,7 @@ class YHAdopterCardExampleView: UIView {
data = ["service_adopter_example_marry"]
centerView.snp.remakeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(CGFloat(691).scaleSizeFrom375px(size: 691))
make.height.equalTo(691.fix)
}
}
if type == .other {
......@@ -57,7 +57,7 @@ class YHAdopterCardExampleView: UIView {
data = ["service_adopter_example_other1", "service_adopter_example_other2","service_adopter_example_other3","service_adopter_example_other4"]
centerView.snp.remakeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(CGFloat(701).scaleSizeFrom375px(size: 801))
make.height.equalTo(801.fix)
}
}
......@@ -66,7 +66,7 @@ class YHAdopterCardExampleView: UIView {
data = ["service_adopter_example_travel"]
centerView.snp.remakeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(CGFloat(689).scaleSizeFrom375px(size: 689))
make.height.equalTo(689.fix)
}
}
......@@ -75,7 +75,7 @@ class YHAdopterCardExampleView: UIView {
data = ["service_adopter_example_chinalife"]
centerView.snp.remakeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(CGFloat(422).scaleSizeFrom375px(size: 422))
make.height.equalTo(422.fix)
}
}
......@@ -84,7 +84,7 @@ class YHAdopterCardExampleView: UIView {
data = ["service_adopter_example_chinatravel"]
centerView.snp.remakeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(CGFloat(659).scaleSizeFrom375px(size: 659))
make.height.equalTo(659.fix)
}
}
}
......@@ -245,38 +245,38 @@ extension YHAdopterCardExampleView: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
guard let type = type else { return 0 }
if type == .china {
return CGFloat(507).scaleSizeFrom375px(size: 507) + 20
return 507.fix + 20
}
if type == .resident {
return CGFloat(482).scaleSizeFrom375px(size: 482) + 20
return 482.fix + 20
}
if type == .birth {
return CGFloat(269).scaleSizeFrom375px(size: 269) + 20
return 269.fix + 20
}
if type == .marry {
return CGFloat(968).scaleSizeFrom375px(size: 968) + 20
return 968.fix + 20
}
if type == .travel {
return CGFloat(508).scaleSizeFrom375px(size: 508) + 20
return 508.fix + 20
}
if type == .chinaLife {
return CGFloat(238).scaleSizeFrom375px(size: 238) + 20
return 238.fix + 20
}
if type == .chinaTravel {
return CGFloat(476).scaleSizeFrom375px(size: 476) + 20
return 476.fix + 20
}
if type == .other {
if indexPath.row == 0 {
return CGFloat(204).scaleSizeFrom375px(size: 204) + 20
return 204.fix + 20
}
if indexPath.row == 1 {
return CGFloat(147).scaleSizeFrom375px(size: 147) + 20
return 147.fix + 20
}
if indexPath.row == 2 {
return CGFloat(91).scaleSizeFrom375px(size: 91) + 20
return 91.fix + 20
}
if indexPath.row == 3 {
return CGFloat(91).scaleSizeFrom375px(size: 91) + 20
return 91.fix + 20
}
}
......
......@@ -263,19 +263,19 @@ extension YHAdopterCardOtherGuideView: UITableViewDelegate, UITableViewDataSourc
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.row == 1 {
return CGFloat(204).scaleSizeFrom375px(size: 204) + 20
return 204.fix + 20
}
if indexPath.row == 2 {
return CGFloat(147).scaleSizeFrom375px(size: 147) + 20
return 147.fix + 20
}
if indexPath.row == 3 {
return CGFloat(91).scaleSizeFrom375px(size: 91) + 20
return 91.fix + 20
}
if indexPath.row == 4 {
return CGFloat(91).scaleSizeFrom375px(size: 91) + 20
return 91.fix + 20
}
return CGFloat(68).scaleSizeFrom375px(size: 68) + 20
return 68.fix + 20
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
......
......@@ -104,7 +104,7 @@ extension YHAdopterOtherCardTableViewCell: UICollectionViewDelegate, UICollectio
extension YHAdopterOtherCardTableViewCell : CollectionViewWaterfallLayoutDelegate {
func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
return CGSize(width: CGFloat(168).scaleSizeFrom375px(size: 168), height: 133)
return CGSize(width: 168.fix, height: 133)
}
}
......
......@@ -244,9 +244,9 @@ private extension YHOfficialApprovalResultVC {
view.addSubview(paperImageV)
paperImageV.snp.makeConstraints { make in
make.left.equalToSuperview()
make.top.equalToSuperview().offset(CGFloat(200).scaleSizeFrom375px(size: 200))
make.width.equalTo(CGFloat(294).scaleSizeFrom375px(size: 294))
make.height.equalTo(CGFloat(530).scaleSizeFrom375px(size: 530))
make.top.equalToSuperview().offset(200.fix)
make.width.equalTo(294.fix)
make.height.equalTo(530.fix)
}
paperImageV.layer.zPosition = 0
......@@ -254,27 +254,27 @@ private extension YHOfficialApprovalResultVC {
view.addSubview(docImageV)
docImageV.snp.makeConstraints { make in
make.right.equalToSuperview()
make.top.equalToSuperview().offset(CGFloat(64).scaleSizeFrom375px(size: 64))
make.width.equalTo(CGFloat(294).scaleSizeFrom375px(size: 294))
make.height.equalTo(CGFloat(530).scaleSizeFrom375px(size: 530))
make.top.equalToSuperview().offset(64.fix)
make.width.equalTo(294.fix)
make.height.equalTo(530.fix)
}
docImageV.layer.zPosition = 1
docImageV.addSubview(contentView)
contentView.snp.makeConstraints { make in
make.left.equalTo(CGFloat(50).scaleSizeFrom375px(size: 50))
make.top.equalTo(CGFloat(140).scaleSizeFrom375px(size: 140))
make.width.equalTo(CGFloat(294).scaleSizeFrom375px(size: 294))
make.height.equalTo(CGFloat(530).scaleSizeFrom375px(size: 530))
make.left.equalTo(50.fix)
make.top.equalTo(140.fix)
make.width.equalTo(294.fix)
make.height.equalTo(530.fix)
}
contentView.transform = rotatedTransform()
docImageV.addSubview(penImageV)
penImageV.snp.makeConstraints { make in
make.top.equalToSuperview().offset(CGFloat(204).scaleSizeFrom375px(size: 204))
make.top.equalToSuperview().offset(204.fix)
make.right.equalToSuperview()
make.width.equalTo(CGFloat(67).scaleSizeFrom375px(size: 67))
make.height.equalTo(CGFloat(141).scaleSizeFrom375px(size: 141))
make.width.equalTo(67.fix)
make.height.equalTo(141.fix)
}
penImageV.layer.zPosition = 1
......@@ -292,7 +292,7 @@ private extension YHOfficialApprovalResultVC {
view.addSubview(lightImageV)
lightImageV.snp.makeConstraints { make in
make.top.right.left.equalToSuperview()
make.height.equalTo(CGFloat(543).scaleSizeFrom375px(size: 543))
make.height.equalTo(543.fix)
}
lightImageV.layer.zPosition = 3
......@@ -308,7 +308,7 @@ private extension YHOfficialApprovalResultVC {
bottomContentView.addSubview(tipsLabel)
tipsLabel.snp.makeConstraints { make in
make.bottom.equalToSuperview().offset(CGFloat(-50).scaleSizeFrom375px(size: -50))
make.bottom.equalToSuperview().offset(-50.fix)
make.centerX.equalToSuperview()
}
......@@ -317,17 +317,17 @@ private extension YHOfficialApprovalResultVC {
indicatorView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.height.equalTo(2)
make.bottom.equalTo(tipsLabel.snp.top).offset(CGFloat(-20).scaleSizeFrom375px(size: -20))
make.bottom.equalTo(tipsLabel.snp.top).offset(-20.fix)
}
bottomContentView.addSubview(bannerView)
bannerView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.height.equalTo(CGFloat(148).scaleSizeFrom375px(size: 148))
make.bottom.equalTo(indicatorView.snp.top).offset(CGFloat(-16).scaleSizeFrom375px(size: -16))
make.height.equalTo(148.fix)
make.bottom.equalTo(indicatorView.snp.top).offset(-16.fix)
make.top.equalToSuperview().offset(CGFloat(20).scaleSizeFrom375px(size: 20))
make.top.equalToSuperview().offset(20.fix)
}
bannerView.layer.zPosition = 10
......
......@@ -171,7 +171,7 @@ private extension YHOffivialApprovalSuccessCheckView {
let topMargin = (KScreenHeight/812.0) * 156
closeBtn.snp.makeConstraints { make in
make.top.equalTo(rewardBtn.snp.bottom).offset(topMargin)
make.width.height.equalTo(CGFloat(24).scaleSizeFrom375px(size: 24))
make.width.height.equalTo(24.fix)
make.centerX.equalToSuperview()
}
closeBtn.YH_clickEdgeInsets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
......
......@@ -42,7 +42,7 @@ class YHOffivialApprovalSuccessView: UIView {
make.left.equalTo(5)
make.top.equalTo(0)
make.right.equalTo(-5)
make.height.equalTo(CGFloat(42).scaleSizeFrom375px(size: 42))
make.height.equalTo(42.fix)
}
}
......@@ -64,18 +64,18 @@ class YHOffivialApprovalSuccessView: UIView {
}
addSubview(label)
label.snp.makeConstraints { make in
make.left.equalTo(CGFloat(5).scaleSizeFrom375px(size: 5))
make.top.equalTo(CGFloat(h).scaleSizeFrom375px(size: CGFloat(h)))
make.left.equalTo(5.fix)
make.top.equalTo(CGFloat(h).fix)
make.right.equalTo(-5)
make.height.equalTo(CGFloat(26).scaleSizeFrom375px(size: 26))
make.height.equalTo(26.fix)
}
let line = UIView()
line.backgroundColor = UIColor(hex: 0x881000).withAlphaComponent(0.15)
addSubview(line)
line.snp.makeConstraints { make in
make.left.equalTo(5)
make.top.equalTo(CGFloat(h + 26 + 2).scaleSizeFrom375px(size: CGFloat(h + 26 + 2)))
make.width.equalTo(CGFloat(234).scaleSizeFrom375px(size: 234))
make.top.equalTo(CGFloat(h + 26 + 2).fix)
make.width.equalTo(234.fix)
make.height.equalTo(1)
}
h = h + 26 + 10
......
......@@ -9,16 +9,6 @@
import UIKit
extension CGFloat {
public func scaleSizeFrom375px(size: CGFloat) -> CGFloat {
let screenWidth = UIScreen.main.bounds.width
// 假设设计稿基于375pt宽度,iPhone 6的屏幕宽度
let baseWidth: CGFloat = 375.0
// 计算换算比例
let scale = screenWidth / baseWidth
// 应用换算比例
return size * scale
}
var fix: CGFloat {
let screenWidth = UIScreen.main.bounds.width
// 假设设计稿基于375pt宽度,iPhone 6的屏幕宽度
......
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