You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.5 KiB
60 lines
1.5 KiB
// |
|
// NoDataView.swift |
|
// HPlusFit |
|
// |
|
// Created by lemo. on 2019/9/15. |
|
// Copyright © 2019 lemo. All rights reserved. |
|
// |
|
|
|
import UIKit |
|
|
|
enum NoDataType { |
|
case base |
|
case scanDevice |
|
case sport |
|
|
|
func getImage() -> UIImage? { |
|
switch self { |
|
case .base: |
|
return R.image.default_device() |
|
case .scanDevice: |
|
return R.image.scanDevice_default() |
|
case .sport: |
|
return R.image.sport_default() |
|
} |
|
} |
|
} |
|
|
|
class NoDataView: UIView { |
|
|
|
var imageView: UIImageView! |
|
fileprivate var label: UILabel! |
|
|
|
convenience init(frame: CGRect, tip: String?, type :NoDataType) { |
|
self.init() |
|
self.frame = frame |
|
imageView = UIImageView() |
|
addSubview(imageView) |
|
imageView.image = type.getImage() |
|
label = UILabel().then { |
|
$0.text = tip |
|
$0.textAlignment = .center |
|
$0.numberOfLines = 0 |
|
$0.font = SystemRegularFont(14) |
|
$0.textColor = kHexColor(0x858585) |
|
addSubview($0) |
|
} |
|
} |
|
|
|
override func layoutSubviews() { |
|
imageView.snp.makeConstraints { (make) in |
|
make.top.equalTo(kScaleHeight(66)) |
|
make.height.width.equalTo(kScaleWidth(200)) |
|
make.centerX.equalToSuperview() |
|
} |
|
label.snp.makeConstraints { (make) in |
|
make.centerX.equalToSuperview() |
|
make.top.equalTo(imageView.snp.bottom) |
|
} |
|
} |
|
}
|
|
|