Skip to content

Commit cb824d3

Browse files
author
蔡龙君
committed
feat |> 调整代码规范
1 parent 545cc81 commit cb824d3

File tree

3 files changed

+35
-23
lines changed

3 files changed

+35
-23
lines changed

Example/Pods/Pods.xcodeproj/project.pbxproj

Lines changed: 12 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SFAlertController/Classes/SFAlertCell.swift

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
import UIKit
1010

1111
class SFAlertCell: UITableViewCell {
12+
1213
static var identifier = "SFAlertCell"
1314
/// 分割线
1415
private(set) lazy var separatorView: UIView = {
1516
$0.translatesAutoresizingMaskIntoConstraints = false
1617
$0.backgroundColor = UIColor(red: 0.783922, green: 0.780392, blue: 0.8, alpha: 1)
1718
return $0
1819
}(UIView())
19-
20+
2021
private lazy var leftButton: UIButton = {
2122
$0.setTitleColor(UIColor(red: 0, green: 0.48, blue: 1, alpha: 1), for: .selected)
2223
$0.setTitleColor(UIColor.black, for: .normal)
@@ -25,7 +26,7 @@ class SFAlertCell: UITableViewCell {
2526
$0.addTarget(self, action: #selector(leftButtonTapped), for: .touchUpInside)
2627
return $0
2728
}(UIButton(type: .custom))
28-
29+
2930
private lazy var rightButton: UIButton = {
3031
$0.isHidden = true
3132
$0.setTitleColor(UIColor(red: 0, green: 0.48, blue: 1, alpha: 1), for: .selected)
@@ -34,10 +35,11 @@ class SFAlertCell: UITableViewCell {
3435
$0.addTarget(self, action: #selector(rightButtonTapped), for: .touchUpInside)
3536
return $0
3637
}(UIButton(type: .custom))
37-
38+
3839
var leftCompletion: (() -> Void)?
40+
3941
var rightCompletion: (() -> Void)?
40-
42+
4143
/// 内容视图
4244
private lazy var stackView: UIStackView = {
4345
$0.translatesAutoresizingMaskIntoConstraints = false
@@ -46,22 +48,26 @@ class SFAlertCell: UITableViewCell {
4648
$0.axis = .horizontal
4749
return $0
4850
}(UIStackView(arrangedSubviews: [leftButton, rightButton]))
49-
51+
5052
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
5153
super.init(style: style, reuseIdentifier: reuseIdentifier)
5254
configSubviews()
55+
configLocation()
5356
}
54-
57+
5558
required init?(coder aDecoder: NSCoder) {
5659
super.init(coder: aDecoder)
5760
configSubviews()
61+
configLocation()
5862
}
5963
}
6064

6165
/// public
6266
extension SFAlertCell {
63-
func config(using leftButtonType: SFAlertController.AlertButton, rightButtonType: SFAlertController.AlertButton? = nil) {
64-
67+
68+
func config(using leftButtonType: SFAlertController.AlertButton,
69+
rightButtonType: SFAlertController.AlertButton? = nil) {
70+
6571
configButton(leftButton, using: leftButtonType)
6672
guard let rightButtonType = rightButtonType else {
6773
separatorView.isHidden = true
@@ -75,12 +81,16 @@ extension SFAlertCell {
7581

7682
/// private
7783
extension SFAlertCell {
78-
84+
7985
private func configSubviews() {
8086
contentView.addSubview(stackView)
8187
contentView.addSubview(separatorView)
8288
selectionStyle = .none
8389
contentView.backgroundColor = UIColor(red: 0.783922, green: 0.780392, blue: 0.8, alpha: 1)
90+
91+
}
92+
93+
private func configLocation() {
8494
stackView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 0.5).isActive = true
8595
stackView.leftAnchor.constraint(equalTo: contentView.leftAnchor).isActive = true
8696
stackView.rightAnchor.constraint(equalTo: contentView.rightAnchor).isActive = true
@@ -90,6 +100,7 @@ extension SFAlertCell {
90100
separatorView.centerXAnchor.constraint(equalTo: contentView.centerXAnchor).isActive = true
91101
separatorView.widthAnchor.constraint(equalToConstant: 0.5).isActive = true
92102
separatorView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor).isActive = true
103+
93104
}
94105

95106
private func configButton(_ button: UIButton, using type: SFAlertController.AlertButton) {

SFAlertController/Classes/Extensions.swift renamed to SFAlertController/Classes/SFAlertHeaderView+Additions.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
//
2-
// Extensions.swift
2+
// SFAlertHeaderView+Additions.swift
33
// SFAlertController
44
//
55
// Created by 花菜 on 2019/8/28.
66
// Copyright © 2019 花菜. All rights reserved.
77
//
88

99
import Foundation
10+
1011
public extension SFAlertController {
12+
1113
/// 显示样式
1214
enum Style: Int {
1315
case sheet

0 commit comments

Comments
 (0)