mirror of
https://github.com/Finb/Bark.git
synced 2025-12-08 21:36:01 +00:00
设置页显示版本号
This commit is contained in:
parent
d3053ad875
commit
6badbec561
@ -28,9 +28,7 @@ class MessageSettingsViewController: BaseViewController<MessageSettingsViewModel
|
||||
tableView.register(SpacerCell.self, forCellReuseIdentifier: "\(SpacerCell.self)")
|
||||
tableView.register(DonateCell.self, forCellReuseIdentifier: "\(DonateCell.self)")
|
||||
|
||||
tableView.estimatedSectionFooterHeight = 10
|
||||
tableView.estimatedSectionHeaderHeight = 10
|
||||
tableView.sectionFooterHeight = UITableView.automaticDimension
|
||||
tableView.sectionHeaderHeight = UITableView.automaticDimension
|
||||
|
||||
let footer = MessageSettingFooter()
|
||||
@ -316,4 +314,20 @@ extension MessageSettingsViewController: UITableViewDelegate {
|
||||
footerView.titleLabel.text = footer
|
||||
return footerView
|
||||
}
|
||||
|
||||
/// FUCK iOS, insetGrouped 和 tableView.sectionFooterHeight = UITableView.automaticDimension 一起用有BUG,因参与计算的宽度口径不一致导致高度可能计算不准确
|
||||
/// 只能自己计算了
|
||||
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
|
||||
guard self.footers.count > section, let footer = self.footers[section] else { return 10 }
|
||||
// 16 是 tableView 左右的间距, 12 是 uilabel 左右的间距
|
||||
let size = CGSize(width: tableView.frame.width - 16 * 2 - 12 * 2, height: .greatestFiniteMagnitude)
|
||||
let rect = (footer as NSString).boundingRect(
|
||||
with: size,
|
||||
options: [.usesLineFragmentOrigin],
|
||||
attributes: [.font: UIFont.preferredFont(ofSize: 12)],
|
||||
context: nil
|
||||
)
|
||||
// 8: top offset, 6:bottom offset
|
||||
return rect.height + 8 + 6
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,20 +10,27 @@ import UIKit
|
||||
|
||||
class MessageSettingFooter: UITextView, UITextViewDelegate {
|
||||
init() {
|
||||
super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 40), textContainer: .none)
|
||||
super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 80), textContainer: .none)
|
||||
self.backgroundColor = UIColor.clear
|
||||
self.isEditable = false
|
||||
self.delegate = self
|
||||
|
||||
self.font = UIFont.preferredFont(ofSize: 12)
|
||||
self.textColor = BKColor.grey.darken1
|
||||
// 版本号
|
||||
let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? ""
|
||||
// build号
|
||||
let buildVersion = Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? ""
|
||||
|
||||
let attr = NSMutableAttributedString(string: NSLocalizedString("privacyPolicy"), attributes: [.link: "privacyPolicy"])
|
||||
let attr = NSMutableAttributedString(string: "Version \(appVersion) (Build \(buildVersion))\n", attributes: [.font: UIFont.preferredFont(ofSize: 12), .foregroundColor: BKColor.grey.darken1])
|
||||
attr.append(NSAttributedString(string: NSLocalizedString("privacyPolicy"), attributes: [.link: "privacyPolicy"]))
|
||||
attr.append(NSAttributedString(string: " · "))
|
||||
attr.append(NSAttributedString(string: NSLocalizedString("userAgreement"), attributes: [.link: "userAgreement"]))
|
||||
attr.append(NSAttributedString(string: " · "))
|
||||
attr.append(NSAttributedString(string: NSLocalizedString("restoreSubscription"), attributes: [.link: "restoreSubscription"]))
|
||||
|
||||
let style = NSMutableParagraphStyle()
|
||||
style.lineSpacing = 6
|
||||
attr.addAttribute(.paragraphStyle, value: style, range: NSRange(location: 0, length: attr.length))
|
||||
|
||||
self.attributedText = attr
|
||||
self.linkTextAttributes = [.foregroundColor: BKColor.grey.darken1, .underlineStyle: NSUnderlineStyle.single.rawValue]
|
||||
self.textAlignment = .center
|
||||
|
||||
@ -48,9 +48,9 @@ class SettingSectionFooter: UIView {
|
||||
self.addSubview(titleLabel)
|
||||
titleLabel.snp.makeConstraints { make in
|
||||
make.top.equalTo(8)
|
||||
make.bottom.equalTo(-6)
|
||||
// make.bottom.equalTo(-6)
|
||||
make.left.equalTo(12)
|
||||
make.right.equalTo(-8)
|
||||
make.right.equalTo(-12)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user