diff --git a/LaserMethane.xcworkspace/xcuserdata/a203.xcuserdatad/UserInterfaceState.xcuserstate b/LaserMethane.xcworkspace/xcuserdata/a203.xcuserdatad/UserInterfaceState.xcuserstate index b6d908d..92b401c 100644 --- a/LaserMethane.xcworkspace/xcuserdata/a203.xcuserdatad/UserInterfaceState.xcuserstate +++ b/LaserMethane.xcworkspace/xcuserdata/a203.xcuserdatad/UserInterfaceState.xcuserstate Binary files differ diff --git a/LaserMethane.xcworkspace/xcuserdata/a203.xcuserdatad/UserInterfaceState.xcuserstate b/LaserMethane.xcworkspace/xcuserdata/a203.xcuserdatad/UserInterfaceState.xcuserstate index b6d908d..92b401c 100644 --- a/LaserMethane.xcworkspace/xcuserdata/a203.xcuserdatad/UserInterfaceState.xcuserstate +++ b/LaserMethane.xcworkspace/xcuserdata/a203.xcuserdatad/UserInterfaceState.xcuserstate Binary files differ diff --git a/LaserMethane/ViewController/Settings/SettingViewController.swift b/LaserMethane/ViewController/Settings/SettingViewController.swift index 726985c..6bb7d34 100644 --- a/LaserMethane/ViewController/Settings/SettingViewController.swift +++ b/LaserMethane/ViewController/Settings/SettingViewController.swift @@ -8,6 +8,7 @@ import Alamofire import AudioToolbox import KeychainAccess +import SnapKit import SwiftyJSON import UIKit @@ -50,7 +51,7 @@ func addFooterButton() { // 先添加View,然后再在View里面添加UIButton - let footerView = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 200)) + let footerView = UIView(frame: CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: SCREEN_HEIGHT - 57 * 6)) let button = UIButton(type: .roundedRect) button.setTitle("退出登录", for: .normal) @@ -58,10 +59,13 @@ button.titleLabel?.font = UIFont.systemFont(ofSize: CGFloat(20)) button.layer.cornerRadius = 18.0 button.backgroundColor = .systemBlue - button.frame = CGRect(x: 35, y: 100, width: 320, height: 36) button.addTarget(self, action: #selector(loginOutAction), for: .touchUpInside) - footerView.addSubview(button) + button.snp.makeConstraints { (make) -> Void in + make.size.equalTo(CGSize(width: 320, height: 36)) + make.centerX.equalToSuperview() + make.top.equalTo(footerView.frame.height * 0.6) + } tableView.tableFooterView = footerView } diff --git a/LaserMethane.xcworkspace/xcuserdata/a203.xcuserdatad/UserInterfaceState.xcuserstate b/LaserMethane.xcworkspace/xcuserdata/a203.xcuserdatad/UserInterfaceState.xcuserstate index b6d908d..92b401c 100644 --- a/LaserMethane.xcworkspace/xcuserdata/a203.xcuserdatad/UserInterfaceState.xcuserstate +++ b/LaserMethane.xcworkspace/xcuserdata/a203.xcuserdatad/UserInterfaceState.xcuserstate Binary files differ diff --git a/LaserMethane/ViewController/Settings/SettingViewController.swift b/LaserMethane/ViewController/Settings/SettingViewController.swift index 726985c..6bb7d34 100644 --- a/LaserMethane/ViewController/Settings/SettingViewController.swift +++ b/LaserMethane/ViewController/Settings/SettingViewController.swift @@ -8,6 +8,7 @@ import Alamofire import AudioToolbox import KeychainAccess +import SnapKit import SwiftyJSON import UIKit @@ -50,7 +51,7 @@ func addFooterButton() { // 先添加View,然后再在View里面添加UIButton - let footerView = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 200)) + let footerView = UIView(frame: CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: SCREEN_HEIGHT - 57 * 6)) let button = UIButton(type: .roundedRect) button.setTitle("退出登录", for: .normal) @@ -58,10 +59,13 @@ button.titleLabel?.font = UIFont.systemFont(ofSize: CGFloat(20)) button.layer.cornerRadius = 18.0 button.backgroundColor = .systemBlue - button.frame = CGRect(x: 35, y: 100, width: 320, height: 36) button.addTarget(self, action: #selector(loginOutAction), for: .touchUpInside) - footerView.addSubview(button) + button.snp.makeConstraints { (make) -> Void in + make.size.equalTo(CGSize(width: 320, height: 36)) + make.centerX.equalToSuperview() + make.top.equalTo(footerView.frame.height * 0.6) + } tableView.tableFooterView = footerView } diff --git a/LaserMethane/ViewController/Settings/SingModeSettingViewController.swift b/LaserMethane/ViewController/Settings/SingModeSettingViewController.swift index 269ac39..88d09ae 100644 --- a/LaserMethane/ViewController/Settings/SingModeSettingViewController.swift +++ b/LaserMethane/ViewController/Settings/SingModeSettingViewController.swift @@ -7,6 +7,7 @@ import AudioToolbox import KeychainAccess +import SnapKit import UIKit class SingModeSettingViewController: UIViewController { @@ -28,8 +29,35 @@ tableView.register(UINib(nibName: "SwitchTableViewCell", bundle: nil), forCellReuseIdentifier: "switchTableViewCell") tableView.dataSource = self tableView.delegate = self - // 去掉tableView底部多余的线 - tableView.tableFooterView = UIView(frame: CGRect.zero) + // 添加底部按钮 + addFooterButton() + } + + func addFooterButton() { + // 先添加View,然后再在View里面添加UIButton + let footerView = UIView(frame: CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: SCREEN_HEIGHT - 57 * 3)) + + let button = UIButton(type: .roundedRect) + button.setTitle("回到登录页", for: .normal) + button.setTitleColor(.white, for: .normal) + button.titleLabel?.font = UIFont.systemFont(ofSize: CGFloat(20)) + button.layer.cornerRadius = 18.0 + button.backgroundColor = .systemBlue + button.addTarget(self, action: #selector(toLoginViewController), for: .touchUpInside) + footerView.addSubview(button) + button.snp.makeConstraints { (make) -> Void in + make.size.equalTo(CGSize(width: 320, height: 36)) + make.centerX.equalToSuperview() + make.top.equalTo(footerView.frame.height * 0.7) + } + tableView.tableFooterView = footerView + } + + @objc func toLoginViewController(_ sender: UIButton) { + let destinationController = LoginViewController(nibName: "LoginViewController", bundle: nil) + destinationController.modalPresentationStyle = UIModalPresentationStyle.fullScreen + destinationController.modalTransitionStyle = UIModalTransitionStyle.coverVertical + present(destinationController, animated: true, completion: nil) } }