增加占位图
This commit is contained in:
parent
16bfd15395
commit
64857ea501
@ -101,4 +101,8 @@ extension UIColor {
|
|||||||
static func colorB5B5B5(alpha: CGFloat = 1) -> UIColor {
|
static func colorB5B5B5(alpha: CGFloat = 1) -> UIColor {
|
||||||
return UIColor(rgb: 0xB5B5B5, alpha: alpha)
|
return UIColor(rgb: 0xB5B5B5, alpha: alpha)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static func colorC4C4C4(alpha: CGFloat = 1) -> UIColor {
|
||||||
|
return UIColor(rgb: 0xC4C4C4, alpha: alpha)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,14 @@ import UIKit
|
|||||||
|
|
||||||
class VPImageView: UIImageView {
|
class VPImageView: UIImageView {
|
||||||
|
|
||||||
var placeholderColor = UIColor.gray
|
var placeholderColor = UIColor.colorC4C4C4()
|
||||||
|
|
||||||
|
private lazy var placeholderImageView: UIImageView = {
|
||||||
|
let imageView = UIImageView(image: UIImage(named: "placeholder_image_01"))
|
||||||
|
imageView.isHidden = true
|
||||||
|
imageView.contentMode = .scaleAspectFit
|
||||||
|
return imageView
|
||||||
|
}()
|
||||||
|
|
||||||
override init(frame: CGRect) {
|
override init(frame: CGRect) {
|
||||||
super.init(frame: frame)
|
super.init(frame: frame)
|
||||||
@ -36,7 +43,10 @@ class VPImageView: UIImageView {
|
|||||||
self.layer.masksToBounds = true
|
self.layer.masksToBounds = true
|
||||||
if image == nil {
|
if image == nil {
|
||||||
self.backgroundColor = self.placeholderColor
|
self.backgroundColor = self.placeholderColor
|
||||||
|
placeholderImageView.isHidden = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addSubview(placeholderImageView)
|
||||||
}
|
}
|
||||||
|
|
||||||
override var image: UIImage? {
|
override var image: UIImage? {
|
||||||
@ -48,7 +58,20 @@ class VPImageView: UIImageView {
|
|||||||
self.backgroundColor = nil
|
self.backgroundColor = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if image == nil {
|
||||||
|
placeholderImageView.isHidden = false
|
||||||
|
} else {
|
||||||
|
placeholderImageView.isHidden = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override func layoutSubviews() {
|
||||||
|
super.layoutSubviews()
|
||||||
|
|
||||||
|
placeholderImageView.frame = .init(x: 0, y: 0, width: self.bounds.width * (2 / 3), height: self.bounds.height * (2 / 3))
|
||||||
|
placeholderImageView.center = .init(x: self.bounds.width / 2, y: self.bounds.height / 2)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,8 +47,8 @@ class VPSearchViewController: VPViewController {
|
|||||||
vp_setupUI()
|
vp_setupUI()
|
||||||
vp_addAction()
|
vp_addAction()
|
||||||
|
|
||||||
let tap = UITapGestureRecognizer(target: self, action: #selector(handleScreen))
|
// let tap = UITapGestureRecognizer(target: self, action: #selector(handleScreen))
|
||||||
self.view.addGestureRecognizer(tap)
|
// self.view.addGestureRecognizer(tap)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
Veloria/Source/Assets.xcassets/image/placeholder_image_01.imageset/Contents.json
vendored
Normal file
22
Veloria/Source/Assets.xcassets/image/placeholder_image_01.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "加载占位图-切图图标@2x.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "加载占位图-切图图标@3x.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
BIN
Veloria/Source/Assets.xcassets/image/placeholder_image_01.imageset/加载占位图-切图图标@2x.png
vendored
Normal file
BIN
Veloria/Source/Assets.xcassets/image/placeholder_image_01.imageset/加载占位图-切图图标@2x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.2 KiB |
BIN
Veloria/Source/Assets.xcassets/image/placeholder_image_01.imageset/加载占位图-切图图标@3x.png
vendored
Normal file
BIN
Veloria/Source/Assets.xcassets/image/placeholder_image_01.imageset/加载占位图-切图图标@3x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
BIN
资料/授权文件/WechatIMG1.jpg
Normal file
BIN
资料/授权文件/WechatIMG1.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.8 MiB |
Loading…
x
Reference in New Issue
Block a user