-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from teambition/feature/support-section
DropdownMenu support section
- Loading branch information
Showing
10 changed files
with
234 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
DropdownMenu.xcodeproj/xcuserdata/wangwei.xcuserdatad/xcschemes/xcschememanagement.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>SuppressBuildableAutocreation</key> | ||
<dict> | ||
<key>ACE6DB6B1CF74183005C6667</key> | ||
<dict> | ||
<key>primary</key> | ||
<true/> | ||
</dict> | ||
<key>ACE6DB751CF74183005C6667</key> | ||
<dict> | ||
<key>primary</key> | ||
<true/> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
Binary file added
BIN
+20.3 KB
DropdownMenu.xcworkspace/xcuserdata/wangwei.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
5 changes: 5 additions & 0 deletions
5
DropdownMenu.xcworkspace/xcuserdata/wangwei.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Bucket | ||
type = "0" | ||
version = "2.0"> | ||
</Bucket> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// | ||
// SectionHeader.swift | ||
// DropdownMenu | ||
// | ||
// Created by WangWei on 2016/10/9. | ||
// Copyright © 2016年 teambition. All rights reserved. | ||
// | ||
|
||
open class SectionHeader: UIView { | ||
var titleLabel: UILabel! | ||
var style: SectionHeaderStyle = SectionHeaderStyle() | ||
|
||
convenience init(style: SectionHeaderStyle) { | ||
self.init(frame: CGRect.zero) | ||
self.style = style | ||
commonInit() | ||
} | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
} | ||
|
||
required public init?(coder aDecoder: NSCoder) { | ||
super.init(coder: aDecoder) | ||
} | ||
|
||
func commonInit() { | ||
titleLabel = UILabel() | ||
titleLabel.translatesAutoresizingMaskIntoConstraints = false | ||
titleLabel.font = style.font | ||
titleLabel.textColor = style.textColor | ||
backgroundColor = style.backgroundColor | ||
addSubview(titleLabel) | ||
updateTitleLabelConstraint() | ||
} | ||
|
||
func updateTitleLabelConstraint() { | ||
let constraints = NSLayoutConstraint.constraints(withVisualFormat: "H:|-leftPadding-[titleLabel]->=20-|", options: [], metrics: ["leftPadding": style.leftPadding], views: ["titleLabel": titleLabel]) | ||
addConstraints(constraints) | ||
if style.shouldTitleCenterVertically { | ||
let centerY = NSLayoutConstraint(item: titleLabel, attribute: .centerY, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1.0, constant: 0) | ||
addConstraint(centerY) | ||
} else { | ||
let vConstraints = NSLayoutConstraint(item: titleLabel, attribute: .bottom, relatedBy: .equal, toItem: self, attribute: .bottom, multiplier: 1.0, constant: style.bottomPadding) | ||
addConstraint(vConstraints) | ||
} | ||
} | ||
} | ||
|
||
|
||
public struct SectionHeaderStyle { | ||
|
||
/// leftPadding for title label, default is `20` | ||
public var leftPadding: CGFloat = 20 | ||
/// bottom padding for title label, default is `10`, | ||
/// will be ignored when `shouldTitleCenterVertically` is `true` | ||
public var bottomPadding: CGFloat = 10 | ||
/// should title label center in axis Y, default is `true` | ||
public var shouldTitleCenterVertically: Bool = true | ||
|
||
/// title label font, default is `UIFont.systemFont(ofSize: 14)` | ||
public var font: UIFont = UIFont.systemFont(ofSize: 14) | ||
/// title label textColor, default is A6A6A6 | ||
public var textColor: UIColor = UIColor(red: 166.0/255.0, green: 166.0/255.0, blue: 166.0/255.0, alpha: 1.0) | ||
/// backgroundColor for header, default is F2F2F2 | ||
public var backgroundColor: UIColor = UIColor(red: 242.0/255.0, green: 242.0/255.0, blue: 242.0/255.0, alpha: 1.0) | ||
|
||
public init() { | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...pdownMenuDemo.xcodeproj/xcuserdata/wangwei.xcuserdatad/xcschemes/xcschememanagement.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>SuppressBuildableAutocreation</key> | ||
<dict> | ||
<key>ACE6DB8E1CF741F6005C6667</key> | ||
<dict> | ||
<key>primary</key> | ||
<true/> | ||
</dict> | ||
<key>ACE6DBA21CF741F6005C6667</key> | ||
<dict> | ||
<key>primary</key> | ||
<true/> | ||
</dict> | ||
<key>ACE6DBAD1CF741F6005C6667</key> | ||
<dict> | ||
<key>primary</key> | ||
<true/> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.