Commit b4b0ecc2 authored by yqz's avatar yqz

内购 样式修改

parent 42c0bd8c
...@@ -158,6 +158,7 @@ class HomeNoAdsViewController: UIViewController, NoAdsStackDataSource { ...@@ -158,6 +158,7 @@ class HomeNoAdsViewController: UIViewController, NoAdsStackDataSource {
sview.setTitle(content, for: .normal) sview.setTitle(content, for: .normal)
sview.setTitleColor(color, for: .normal) sview.setTitleColor(color, for: .normal)
sview.titleLabel?.font = font sview.titleLabel?.font = font
sview.isSelected = false;
sview.sizeToFit() sview.sizeToFit()
let attributes: [NSAttributedString.Key: Any] = [ let attributes: [NSAttributedString.Key: Any] = [
...@@ -167,7 +168,7 @@ class HomeNoAdsViewController: UIViewController, NoAdsStackDataSource { ...@@ -167,7 +168,7 @@ class HomeNoAdsViewController: UIViewController, NoAdsStackDataSource {
] ]
let attributedString = NSAttributedString(string: content, attributes: attributes) let attributedString = NSAttributedString(string: content, attributes: attributes)
sview.setAttributedTitle(attributedString, for: .normal) sview.setAttributedTitle(attributedString, for: .normal)
sview.addTarget(self, action: #selector(terms), for: .touchUpInside) sview.addTarget(self, action: #selector(terms(_:)), for: .touchUpInside)
sview.sizeToFit() sview.sizeToFit()
contentScroll.addSubview(sview) contentScroll.addSubview(sview)
return sview return sview
...@@ -198,6 +199,41 @@ class HomeNoAdsViewController: UIViewController, NoAdsStackDataSource { ...@@ -198,6 +199,41 @@ class HomeNoAdsViewController: UIViewController, NoAdsStackDataSource {
return sview return sview
}() }()
private lazy var privavye_Label: UILabel = {
let priva = UILabel()
priva.font = UIFont.systemFont(ofSize: 14)
priva.textColor = .gray
priva.text = ""
priva.numberOfLines = 0
priva.clipsToBounds = true
priva.isUserInteractionEnabled = true
let tap = UITapGestureRecognizer(target: self, action: #selector(labelTapped(_:)))
priva.addGestureRecognizer(tap)
contentScroll.addSubview(priva)
return priva
}()
@objc private func labelTapped(_ gesture: UITapGestureRecognizer) {
let location = gesture.location(in: privavye_Label)
let strs:NSString = "privacy policy"
let frssss = strs.boundingRect(with: CGSizeMake(.infinity, .infinity), options: .truncatesLastVisibleLine, attributes: [NSAttributedString.Key.font : privavye_Label.font], context: nil)
let frame1 = CGRectMake(0, privavye_Label.height-25, CGRectGetWidth(frssss), 25)
let frame2 = CGRectMake(CGRectGetWidth(frssss)+20, privavye_Label.height-25, 90, 25)
if frame1.contains(location) {
Print("点击了隐私")
let vc:PrivacyPolicyWebViewController = PrivacyPolicyWebViewController()
vc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(vc, animated: true)
}else if frame2.contains(location){
Print("点击了terms")
let vc:TermOfUseWebViewController = TermOfUseWebViewController()
vc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(vc, animated: true)
}
}
private let data:[[String:String]] = [ private let data:[[String:String]] = [
["icon":"ic_unsel_com","t":"Intelligent cleaning of similar photos"], ["icon":"ic_unsel_com","t":"Intelligent cleaning of similar photos"],
["icon":"ic_unsel_com","t":"Unlimited usage times"], ["icon":"ic_unsel_com","t":"Unlimited usage times"],
...@@ -264,12 +300,31 @@ extension HomeNoAdsViewController : UIScrollViewDelegate { ...@@ -264,12 +300,31 @@ extension HomeNoAdsViewController : UIScrollViewDelegate {
HomePayModel.share.restore() HomePayModel.share.restore()
} }
@objc func terms() -> Void { @objc func terms(_ sender:UIButton) -> Void {
DispatchQueue.main.async {[weak self] in DispatchQueue.main.async {[weak self] in
guard let self else {return} guard let self else {return}
let vc:TermOfUseWebViewController = TermOfUseWebViewController() sender.isSelected = !sender.isSelected
vc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(vc, animated: true) let strs:NSString = sender.isSelected ? "We offer 1-year and lifetime subscriptions. The price is clearly displayed within the application.\n\n·After the purchase confirmation, your iTunes account will be charged.\n·Unless the automatic update is turned off at least 24 hours before the end of the current cycle, the subscription will be automatically updated.\n·Your account will be renewed within 24 hours before the end of the current cycle cost.\n·You can go to the \"Account Settings\" in the iTunes store to manage your subscriptions and turn off auto renewal.\n·If provided, if you choose to use our free trial version, any unused portion during the free trial period will become invalid when you purchase a publication subscription, if applicable.\n·If you choose not to purchase the AI PhoneManager Pro version, you can continue to use it for free and enjoy PhoneManager.\n\nYour personal data is securely stored in PhoneManager, please make sure to read our \nprivacy policy and terms of use." : ""
let attribtit = NSMutableAttributedString(string:strs as String , attributes: [:])
if strs.length > 3 {
let rang = strs.range(of: "privacy policy")
attribtit.addAttributes([NSAttributedString.Key.font : UIFont.boldSystemFont(ofSize: 14),NSAttributedString.Key.underlineStyle:NSUnderlineStyle.single.rawValue,.link:"appscheme://private"], range: rang)
let rang1 = strs.range(of: "terms of use")
attribtit.addAttributes([NSAttributedString.Key.font : UIFont.boldSystemFont(ofSize: 14),NSAttributedString.Key.underlineStyle:NSUnderlineStyle.single.rawValue,.link:"appscheme://terms"], range: rang1)
}
privavye_Label.attributedText = attribtit
self.view.layoutIfNeeded()
DispatchQueue.main.async {
let height = CGRectGetMaxY(self.privavye_Label.frame)
self.contentScroll.contentSize = CGSize(width: 0, height: height + 30)
}
// let vc:TermOfUseWebViewController = TermOfUseWebViewController()
// vc.hidesBottomBarWhenPushed = true
// self.navigationController?.pushViewController(vc, animated: true)
} }
} }
...@@ -343,6 +398,7 @@ extension HomeNoAdsViewController : UIScrollViewDelegate { ...@@ -343,6 +398,7 @@ extension HomeNoAdsViewController : UIScrollViewDelegate {
private func setUI() -> Void { private func setUI() -> Void {
topBackimg.snp.makeConstraints { make in topBackimg.snp.makeConstraints { make in
make.left.right.top.equalToSuperview() make.left.right.top.equalToSuperview()
make.height.equalTo(topBackimg.snp.width).multipliedBy(182.0/375.0)
} }
closeBtn.snp.makeConstraints { make in closeBtn.snp.makeConstraints { make in
...@@ -409,12 +465,18 @@ extension HomeNoAdsViewController : UIScrollViewDelegate { ...@@ -409,12 +465,18 @@ extension HomeNoAdsViewController : UIScrollViewDelegate {
make.centerY.equalTo(ppBtn) make.centerY.equalTo(ppBtn)
make.right.equalTo(buybut.snp.right) make.right.equalTo(buybut.snp.right)
} }
privavye_Label.snp.makeConstraints { make in
make.left.equalTo(ppBtn.snp.left)
make.right.equalTo(restoreBtn.snp.right)
make.top.equalTo(ppBtn.snp.bottom).offset(15)
}
self.type = 0 self.type = 0
self.view.layoutIfNeeded() self.view.layoutIfNeeded()
DispatchQueue.main.asyncAfter(deadline: .now()+0.1) { DispatchQueue.main.asyncAfter(deadline: .now()+0.1) {
self.buybut.layer.cornerRadius = CGRectGetHeight(self.buybut.frame) / 2.0 self.buybut.layer.cornerRadius = CGRectGetHeight(self.buybut.frame) / 2.0
self.scroll.contentSize = CGSize(width: CGRectGetWidth(self.scroll.frame) * 3.0, height: 0) self.scroll.contentSize = CGSize(width: CGRectGetWidth(self.scroll.frame) * 3.0, height: 0)
let height = CGRectGetMaxY(self.restoreBtn.frame) let height = CGRectGetMaxY(self.privavye_Label.frame)
self.contentScroll.contentSize = CGSize(width: 0, height: height + 30) self.contentScroll.contentSize = CGSize(width: 0, height: height + 30)
} }
} }
......
...@@ -24,9 +24,12 @@ class HomePayViewController:UIViewController { ...@@ -24,9 +24,12 @@ class HomePayViewController:UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = .green view.backgroundColor = .white
addViews() addViews()
storeKeD() storeKeD()
scroll.snp.makeConstraints { make in
make.left.right.top.bottom.equalToSuperview()
}
} }
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
...@@ -39,11 +42,22 @@ class HomePayViewController:UIViewController { ...@@ -39,11 +42,22 @@ class HomePayViewController:UIViewController {
homePayView?.playAnimationWithDelay() homePayView?.playAnimationWithDelay()
} }
lazy var scroll: UIScrollView = {
let scroll = UIScrollView()
scroll.backgroundColor = .clear
scroll.contentInsetAdjustmentBehavior = .never
view.addSubview(scroll)
return scroll
}()
private func addViews() { private func addViews() {
homePayView = HomePayView(frame: view.bounds) homePayView = HomePayView(frame: view.bounds)
view.addSubview(homePayView!) scroll.addSubview(homePayView!)
homePayView?.snp.makeConstraints { make in
make.left.top.equalToSuperview()
make.width.equalTo(scroll.snp.width)
}
homePayView?.callBack = {[weak self] status in homePayView?.callBack = {[weak self] status in
guard let self else {return} guard let self else {return}
if let operstatus = status as? OperStatus { if let operstatus = status as? OperStatus {
...@@ -66,11 +80,16 @@ class HomePayViewController:UIViewController { ...@@ -66,11 +80,16 @@ class HomePayViewController:UIViewController {
self.payTouch() self.payTouch()
break break
case .swit: case .swit:
break break
case .restore: case .restore:
self.restoreClick() self.restoreClick()
break break
case .change:
DispatchQueue.main.async {
let contentSize = CGRectGetHeight(self.homePayView?.frame ?? CGRect())
self.scroll.contentSize = CGSizeMake(0, contentSize)
}
break
} }
} }
} }
......
...@@ -25,6 +25,7 @@ enum CommonPush { ...@@ -25,6 +25,7 @@ enum CommonPush {
case swit case swit
case pay case pay
case restore case restore
case change
} }
enum tabbarType { enum tabbarType {
......
...@@ -56,3 +56,47 @@ extension UILabel { ...@@ -56,3 +56,47 @@ extension UILabel {
self.width = width self.width = width
} }
} }
extension UILabel {
func isTapLocationInTextRange(_ gesture: UITapGestureRecognizer, range: NSRange) -> Bool {
let layoutManager = NSLayoutManager()
let textContainer = NSTextContainer(size: .zero)
let textStorage = NSTextStorage(attributedString: self.attributedText ?? NSAttributedString())
layoutManager.addTextContainer(textContainer)
textStorage.addLayoutManager(layoutManager)
textContainer.lineFragmentPadding = 0
textContainer.lineBreakMode = self.lineBreakMode
textContainer.maximumNumberOfLines = self.numberOfLines
textContainer.size = self.bounds.size
let location = gesture.location(in: self)
let textBoundingBox = layoutManager.usedRect(for: textContainer)
let alignmentOffset = self.alignmentOffsetForText(in: textBoundingBox)
let touchLocation = CGPoint(
x: (location.x - alignmentOffset),
y: (location.y - textBoundingBox.minY)
)
let index = layoutManager.characterIndex(
for: touchLocation,
in: textContainer,
fractionOfDistanceBetweenInsertionPoints: nil
)
return NSLocationInRange(index, range)
}
private func alignmentOffsetForText(in rect: CGRect) -> CGFloat {
switch self.textAlignment {
case .left, .natural, .justified:
return 0
case .center:
return (self.bounds.width - rect.width) / 2
case .right:
return self.bounds.width - rect.width
@unknown default:
return 0
}
}
}
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