Skip to content

Commit f545117

Browse files
committed
Add advanced method
1 parent fec3b8f commit f545117

File tree

8 files changed

+71
-3
lines changed

8 files changed

+71
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Updates
2+
3+
## [v2.0.10](https://github.com/younatics/YNDropDownMenu/releases/tag/2.0.10)
4+
* Add `changeMenu(title: String, status: YNStatus, at index: Int)` method in `YNDropDownView` and `YNDropDownMenu`
5+
26
## [v2.0.9](https://github.com/younatics/YNDropDownMenu/releases/tag/2.0.9)
37
* Add bottom line for seperator
48

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class DropDownView: YNDropDownView {
6868

6969
// Change Menu Title At Index
7070
self.changeMenu(title: "Changed", at: 1)
71+
self.changeMenu(title: "Changed", status: .selected, at: 1)
7172

7273
// Change View At Index
7374
self.changeView(view: UIView(), at: 3)
@@ -90,7 +91,7 @@ view.disabledMenu(at: 2)
9091
view.enabledMenu(at: 3)
9192
```
9293

93-
Always selected button label
94+
Always/Normal selected button label
9495
```swift
9596
view.alwaysSelected(at: 0)
9697
```
@@ -145,6 +146,8 @@ view.hideMenuSpringWithDamping = 0.8
145146
Change Menu Title At Index
146147
```swift
147148
view.changeMenu(title: "Changed", at: 1)
149+
view.changeMenu(title: "Changed", status: .selected, at: 1)
150+
148151
```
149152

150153
Change View At Index
@@ -159,6 +162,7 @@ view.bottomLine.isHidden = false
159162

160163
```
161164

165+
162166
### Deprecated
163167
```swift
164168
extension YNDropDownMenu {

YNDropDownMenu.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'YNDropDownMenu'
11-
s.version = '2.0.9'
11+
s.version = '2.0.10'
1212
s.summary = 'Awesome Dropdown menu for iOS with Swift 3'
1313

1414
s.description = <<-DESC

YNDropDownMenu/Example/DropDownViews.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class ZBFilterMemeView: YNDropDownView {
2626
self.hideMenu()
2727
}
2828
@IBAction func cancelButtonClicked(_ sender: Any) {
29-
self.changeMenu(title: "Changed", at: 1)
29+
// self.changeMenu(title: "Changed", at: 1)
30+
self.changeMenu(title: "Changed", status: .selected, at: 1)
3031
self.hideMenu()
3132

3233
}

YNDropDownMenu/Source/YNDropDownDelegate.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,21 @@ public protocol YNDropDownDelegate: class {
2121
*/
2222
func changeMenu(title: String, at index: Int)
2323

24+
/**
25+
Change view you called. you can call it in YNDropDownMenu or YNDropDownView
26+
27+
- Parameter title: View you want to change
28+
- Parameter status: normal, selected, disabled
29+
- Parameter index: Index should be smaller than your menu counts
30+
*/
31+
func changeMenu(title: String, status: YNStatus, at index: Int)
32+
2433
/**
2534
Change view you called. you can call it in YNDropDownMenu or YNDropDownView
2635

2736
- Parameter view: View you want to change
2837
- Parameter index: Index should be smaller than your menu counts
2938
*/
3039
func changeView(view: UIView, at index: Int)
40+
3141
}

YNDropDownMenu/Source/YNDropDownMenu.swift

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88

99
import UIKit
1010

11+
/// Button status
12+
public enum YNStatus {
13+
case normal
14+
case selected
15+
case disabled
16+
}
17+
1118
/// Main Class for YNDropDownMenu
1219
open class YNDropDownMenu: UIView, YNDropDownDelegate {
1320
internal var opened: Bool = false
@@ -210,16 +217,46 @@ open class YNDropDownMenu: UIView, YNDropDownDelegate {
210217
/**
211218
Change menu title you called. you can call it in YNDropDownMenu or YNDropDownView
212219

220+
- Parameter title: Menu title
213221
- Parameter index: Index should be smaller than your menu counts
214222
*/
215223
open func changeMenu(title: String, at index: Int) {
216224
dropDownButtons?[index].buttonLabel.text = title
225+
}
226+
227+
/**
228+
Change menu title you called. you can call it in YNDropDownMenu or YNDropDownView
229+
230+
- Parameter title: Menu title
231+
- Parameter index: Index should be smaller than your menu counts
232+
*/
233+
open func changeMenu(title: String, status: YNStatus, at index: Int) {
234+
switch status {
235+
case .normal:
236+
dropDownButtons?[index].buttonLabel.text = title
237+
dropDownButtons?[index].buttonLabel.textColor = self.buttonlabelFontColors?.normal
238+
dropDownButtons?[index].buttonLabel.font = self.buttonlabelFonts?.normal
239+
dropDownButtons?[index].isUserInteractionEnabled = true
217240

241+
case .selected:
242+
dropDownButtons?[index].buttonLabel.text = title
243+
dropDownButtons?[index].buttonLabel.textColor = self.buttonlabelFontColors?.selected
244+
dropDownButtons?[index].buttonLabel.font = self.buttonlabelFonts?.selected
245+
dropDownButtons?[index].isUserInteractionEnabled = true
246+
247+
case .disabled:
248+
dropDownButtons?[index].buttonLabel.text = title
249+
dropDownButtons?[index].buttonLabel.textColor = self.buttonlabelFontColors?.disabled
250+
dropDownButtons?[index].buttonLabel.font = self.buttonlabelFonts?.disabled
251+
dropDownButtons?[index].isUserInteractionEnabled = false
252+
}
218253
}
254+
219255

220256
/**
221257
Change view you called. you can call it in YNDropDownMenu or YNDropDownView
222258

259+
- Parameter view: view that you want to change
223260
- Parameter index: Index should be smaller than your menu counts
224261
*/
225262
open func changeView(view: UIView, at index: Int) {

YNDropDownMenu/Source/YNDropDownView.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ open class YNDropDownView: UIView {
3434
self.delegate?.changeMenu(title: title, at: index)
3535
}
3636

37+
/**
38+
Change menu title you called. you can call it in YNDropDownMenu or YNDropDownView
39+
40+
- Parameter title: String
41+
- Parameter status: normal, selected, disabled
42+
- Parameter index: Index should be smaller than your menu counts
43+
*/
44+
open func changeMenu(title: String, status: YNStatus, at index: Int) {
45+
self.delegate?.changeMenu(title: title, status: status, at: index)
46+
}
47+
48+
3749
/**
3850
Change view you called. you can call it in YNDropDownMenu or YNDropDownView
3951

0 commit comments

Comments
 (0)