Commit 13f9c6ab authored by yqz's avatar yqz

Merge branch 'Purchases' into Pay

* Purchases:
  内购 样式修改

# Conflicts:
#	PhoneManager/Class/Session/NoAds/HomeNoAdsViewController.swift
parents b2ff9d1b b4b0ecc2
......@@ -159,6 +159,7 @@ class HomeNoAdsViewController: UIViewController, NoAdsStackDataSource {
sview.setTitle(content, for: .normal)
sview.setTitleColor(color, for: .normal)
sview.titleLabel?.font = font
sview.isSelected = false;
sview.sizeToFit()
let attributes: [NSAttributedString.Key: Any] = [
......@@ -168,7 +169,7 @@ class HomeNoAdsViewController: UIViewController, NoAdsStackDataSource {
]
let attributedString = NSAttributedString(string: content, attributes: attributes)
sview.setAttributedTitle(attributedString, for: .normal)
sview.addTarget(self, action: #selector(terms), for: .touchUpInside)
sview.addTarget(self, action: #selector(terms(_:)), for: .touchUpInside)
sview.sizeToFit()
contentScroll.addSubview(sview)
return sview
......@@ -199,6 +200,41 @@ class HomeNoAdsViewController: UIViewController, NoAdsStackDataSource {
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]] = [
["icon":"ic_unsel_com","t":"Intelligent cleaning of similar photos"],
["icon":"ic_unsel_com","t":"Unlimited usage times"],
......@@ -265,12 +301,31 @@ extension HomeNoAdsViewController : UIScrollViewDelegate {
HomePayModel.share.restore()
}
@objc func terms() -> Void {
@objc func terms(_ sender:UIButton) -> Void {
DispatchQueue.main.async {[weak self] in
guard let self else {return}
let vc:TermOfUseWebViewController = TermOfUseWebViewController()
vc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(vc, animated: true)
sender.isSelected = !sender.isSelected
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,8 +398,13 @@ extension HomeNoAdsViewController : UIScrollViewDelegate {
private func setUI() -> Void {
topBackimg.snp.makeConstraints { make in
<<<<<<< HEAD
make.left.right.equalToSuperview()
make.top.equalToSuperview().offset(-20)
=======
make.left.right.top.equalToSuperview()
make.height.equalTo(topBackimg.snp.width).multipliedBy(182.0/375.0)
>>>>>>> Purchases
}
closeBtn.snp.makeConstraints { make in
......@@ -411,12 +471,18 @@ extension HomeNoAdsViewController : UIScrollViewDelegate {
make.centerY.equalTo(ppBtn)
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.view.layoutIfNeeded()
DispatchQueue.main.asyncAfter(deadline: .now()+0.1) {
self.buybut.layer.cornerRadius = CGRectGetHeight(self.buybut.frame) / 2.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)
}
}
......
......@@ -24,9 +24,12 @@ class HomePayViewController:UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .green
view.backgroundColor = .white
addViews()
storeKeD()
scroll.snp.makeConstraints { make in
make.left.right.top.bottom.equalToSuperview()
}
}
override func viewWillAppear(_ animated: Bool) {
......@@ -39,11 +42,22 @@ class HomePayViewController:UIViewController {
homePayView?.playAnimationWithDelay()
}
lazy var scroll: UIScrollView = {
let scroll = UIScrollView()
scroll.backgroundColor = .clear
scroll.contentInsetAdjustmentBehavior = .never
view.addSubview(scroll)
return scroll
}()
private func addViews() {
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
guard let self else {return}
if let operstatus = status as? OperStatus {
......@@ -66,11 +80,16 @@ class HomePayViewController:UIViewController {
self.payTouch()
break
case .swit:
break
case .restore:
self.restoreClick()
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 {
case swit
case pay
case restore
case change
}
enum tabbarType {
......
......@@ -56,3 +56,47 @@ extension UILabel {
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