4.B SharePanel: 替换字符占位为 imageset 图标
从 docs/res/Images.xcassets 拷贝 shareWechat / shareQQ / shareDouyin 三套 imageset(@1x/@2x/@3x)到 ylgamehall/Assets.xcassets/。SharePanel 按钮从"彩色圆 + 首字"改为 setImage + clipsToBounds + 等比缩放,未安装 平台改 alpha 灰显(与原 daoqi msext SharePanel.m:147 createButtonWithImage 同款写法)。 ylgamehall/ 是 PBXFileSystemSynchronizedRootGroup,无需手改 pbxproj。
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "shareDouyin.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "shareDouyin@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "shareDouyin@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 6.2 KiB |
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "shareQQ.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "shareQQ@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "shareQQ@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "shareWechat.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "shareWechat@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "shareWechat@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
@@ -88,23 +88,23 @@ public final class SharePanel: UIView {
|
||||
let buttonsContainer = UIView(frame: CGRect(x: 0, y: 30, width: screen.width, height: 110))
|
||||
contentView.addSubview(buttonsContainer)
|
||||
|
||||
let buttons: [(title: String, platform: SharePlatform, color: UIColor)] = [
|
||||
("微信", WechatShare.shared, UIColor(red: 0.06, green: 0.69, blue: 0.36, alpha: 1)),
|
||||
("QQ", QQShare.shared, UIColor(red: 0.12, green: 0.51, blue: 0.97, alpha: 1)),
|
||||
("抖音", DouyinShare.shared, .black)
|
||||
let buttons: [(title: String, platform: SharePlatform, imageName: String)] = [
|
||||
("微信", WechatShare.shared, "shareWechat"),
|
||||
("QQ", QQShare.shared, "shareQQ"),
|
||||
("抖音", DouyinShare.shared, "shareDouyin")
|
||||
]
|
||||
|
||||
let totalButtonsWidth = Self.buttonSize * CGFloat(buttons.count)
|
||||
let spacing = (screen.width - totalButtonsWidth) / CGFloat(buttons.count + 1)
|
||||
for (index, b) in buttons.enumerated() {
|
||||
let x = spacing + CGFloat(index) * (Self.buttonSize + spacing)
|
||||
let button = UIButton(type: .system)
|
||||
let button = UIButton(type: .custom)
|
||||
button.frame = CGRect(x: x, y: 0, width: Self.buttonSize, height: Self.buttonSize)
|
||||
button.backgroundColor = b.platform.isInstalled ? b.color : .lightGray
|
||||
button.setImage(UIImage(named: b.imageName), for: .normal)
|
||||
button.imageView?.contentMode = .scaleAspectFit
|
||||
button.layer.cornerRadius = Self.buttonSize / 2
|
||||
button.setTitle(b.title.prefix(1).description, for: .normal)
|
||||
button.setTitleColor(.white, for: .normal)
|
||||
button.titleLabel?.font = .systemFont(ofSize: 22, weight: .medium)
|
||||
button.clipsToBounds = true
|
||||
button.alpha = b.platform.isInstalled ? 1.0 : 0.4
|
||||
button.tag = index
|
||||
button.addTarget(self, action: #selector(handleButtonTap(_:)), for: .touchUpInside)
|
||||
buttonsContainer.addSubview(button)
|
||||
|
||||