Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a517095067 | |||
| 1c37ec6c29 |
+7
-7
@@ -22,7 +22,7 @@ public class AdaptiveButtonAppearance: NSObject {
|
||||
private var buttonsImageInsetsForStateDictionary:Dictionary <String,UIEdgeInsets> = Dictionary<String,UIEdgeInsets>()
|
||||
private var buttonsTitleInsetsForStateDictionary:Dictionary <String,UIOffset> = Dictionary<String,UIOffset>()
|
||||
|
||||
private var buttonsTitleColorsForStateDictionary:Dictionary <String,UIColor> = Dictionary<String,UIColor>()
|
||||
private var buttonsTitleColorsForStateDictionary:Dictionary <String,ControlStateValue> = Dictionary<String,ControlStateValue>()
|
||||
|
||||
func setInsetsFromAdaptiveButtonApperance(adaptiveButtonApperance:AdaptiveButtonAppearance){
|
||||
|
||||
@@ -159,18 +159,18 @@ public class AdaptiveButtonAppearance: NSObject {
|
||||
}
|
||||
|
||||
|
||||
public func setTitleColor(color:UIColor, state:String){
|
||||
public func setTitleColor(color:ControlStateValue, state:String){
|
||||
buttonsTitleColorsForStateDictionary.updateValue(color, forKey:state)
|
||||
}
|
||||
|
||||
public func getTitleColorForState(state:NSString)->UIColor!{
|
||||
public func getTitleColorForState(state:NSString)-> ControlStateValue!{
|
||||
|
||||
var offset:UIColor? = buttonsTitleColorsForStateDictionary[state]
|
||||
if(offset == nil){
|
||||
offset = buttonsTitleColorsForStateDictionary[kDefaultAdaptiveState]?
|
||||
var titleColorState:ControlStateValue? = buttonsTitleColorsForStateDictionary[state]
|
||||
if(titleColorState == nil){
|
||||
titleColorState = buttonsTitleColorsForStateDictionary[kDefaultAdaptiveState]?
|
||||
}
|
||||
|
||||
return offset!
|
||||
return titleColorState!
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+13
-2
@@ -81,8 +81,19 @@ public class AdaptiveButtonsStateManager: NSObject {
|
||||
button.setTitleOffsetToAdaptiveButton?(titleOffset)
|
||||
}
|
||||
|
||||
if let titleColor = buttonApperance.getTitleColorForState(state) {
|
||||
button.setTitleColorToAdaptiveButton?(titleColor)
|
||||
if let titleStateValue:ControlStateValue = buttonApperance.getTitleColorForState(state) {
|
||||
|
||||
switch titleStateValue.normalState! {
|
||||
case .ControlStateColor(let titleColor):
|
||||
button.setTitleColorToAdaptiveButton?(titleColor)
|
||||
break
|
||||
default:
|
||||
//WARNING: Color is default
|
||||
break
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import UIKit
|
||||
|
||||
public enum ControlStateEnum {
|
||||
case ControlStateFont(UIFont), ControlStateImage(UIImage),ControlStateTitle(String),ControlStateInsets(UIEdgeInsets),ControlStateColor(UIColor),UIControlState(UIOffset)
|
||||
case ControlStateFont(UIFont), ControlStateImage(UIImage),ControlStateTitle(String),ControlStateInsets(UIEdgeInsets),ControlStateColor(UIColor),UIControlStateOffset(UIOffset)
|
||||
}
|
||||
|
||||
|
||||
@@ -18,18 +18,121 @@ public class ControlStateValue:ControlStateProtocol{
|
||||
|
||||
public typealias StateEnum = ControlStateEnum
|
||||
|
||||
public var normalState: StateEnum?
|
||||
public var selectedState: StateEnum?
|
||||
public var highlightedState: StateEnum?
|
||||
public var normalState: ControlStateEnum?
|
||||
public var selectedState: ControlStateEnum?
|
||||
public var highlightedState: ControlStateEnum?
|
||||
|
||||
|
||||
public convenience init(valueForNormalState:ControlStateEnum?) {
|
||||
self.init()
|
||||
|
||||
self.normalState = valueForNormalState
|
||||
self.selectedState = valueForNormalState
|
||||
self.highlightedState = valueForNormalState
|
||||
|
||||
public init(image: UIImage) {
|
||||
normalState = .ControlStateImage(image)
|
||||
selectedState = .ControlStateImage(image)
|
||||
highlightedState = .ControlStateImage(image)
|
||||
|
||||
}
|
||||
|
||||
|
||||
public init(color: UIColor) {
|
||||
normalState = .ControlStateColor(color)
|
||||
selectedState = .ControlStateColor(color)
|
||||
highlightedState = .ControlStateColor(color)
|
||||
|
||||
}
|
||||
|
||||
public init(title: String) {
|
||||
normalState = .ControlStateTitle(title)
|
||||
selectedState = .ControlStateTitle(title)
|
||||
highlightedState = .ControlStateTitle(title)
|
||||
}
|
||||
|
||||
public init(insets: UIEdgeInsets) {
|
||||
normalState = .ControlStateInsets(insets)
|
||||
selectedState = .ControlStateInsets(insets)
|
||||
highlightedState = .ControlStateInsets(insets)
|
||||
}
|
||||
|
||||
|
||||
public init(offset: UIOffset) {
|
||||
normalState = .UIControlStateOffset(offset)
|
||||
selectedState = .UIControlStateOffset(offset)
|
||||
highlightedState = .UIControlStateOffset(offset)
|
||||
}
|
||||
|
||||
public init(font: UIFont) {
|
||||
normalState = .ControlStateFont(font)
|
||||
selectedState = .ControlStateFont(font)
|
||||
highlightedState = .ControlStateFont(font)
|
||||
}
|
||||
|
||||
|
||||
|
||||
public func setNormalStateColor(color:UIColor){
|
||||
normalState = .ControlStateColor(color)
|
||||
}
|
||||
|
||||
public func setSelectedStateColor(color:UIColor){
|
||||
selectedState = .ControlStateColor(color)
|
||||
}
|
||||
|
||||
public func setHighlightedStateColor(color:UIColor){
|
||||
highlightedState = .ControlStateColor(color)
|
||||
}
|
||||
|
||||
|
||||
public func setNormalStateImage(image:UIImage){
|
||||
normalState = .ControlStateImage(image)
|
||||
}
|
||||
|
||||
public func seSelectedStateImage(image:UIImage){
|
||||
selectedState = .ControlStateImage(image)
|
||||
}
|
||||
|
||||
public func setHighlightedStateImage(image:UIImage){
|
||||
highlightedState = .ControlStateImage(image)
|
||||
}
|
||||
|
||||
public func setHighlightedStateImage(image:UIImage){
|
||||
highlightedState = .ControlStateImage(image)
|
||||
}
|
||||
|
||||
|
||||
|
||||
public func setNormalStateFont(font:UIFont){
|
||||
normalState = .ControlStateFont(font)
|
||||
}
|
||||
|
||||
public func setSelectedStateFont(font:UIFont){
|
||||
selectedState = .ControlStateFont(font)
|
||||
}
|
||||
|
||||
public func setHighlightedStateFont(font:UIFont){
|
||||
highlightedState = .ControlStateFont(font)
|
||||
}
|
||||
|
||||
|
||||
public func setNormalStateInsets(insets:UIEdgeInsets){
|
||||
normalState = .ControlStateInsets(insets)
|
||||
}
|
||||
|
||||
public func seSelectedStateInsets(insets:UIEdgeInsets){
|
||||
selectedState = .ControlStateInsets(insets)
|
||||
}
|
||||
|
||||
public func setHighlightedStateInsets(insets:UIEdgeInsets){
|
||||
highlightedState = .ControlStateInsets(insets)
|
||||
}
|
||||
|
||||
|
||||
public func setNormalStateFont(offset:UIOffset){
|
||||
normalState = .ControlStateFont(font)
|
||||
}
|
||||
|
||||
public func seSelectedStateFont(font:UIFont){
|
||||
selectedState = .ControlStateFont(font)
|
||||
}
|
||||
|
||||
public func setHighlightedStateFont(font:UIFont){
|
||||
highlightedState = .ControlStateFont(font)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+6
-2
@@ -14,7 +14,9 @@
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "50"
|
||||
endingLineNumber = "50">
|
||||
endingLineNumber = "50"
|
||||
landmarkName = "application(_:didFinishLaunchingWithOptions:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
@@ -252,7 +254,9 @@
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "119"
|
||||
endingLineNumber = "119">
|
||||
endingLineNumber = "119"
|
||||
landmarkName = "buttonsAppearancesGenerate()"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
</Breakpoints>
|
||||
|
||||
BIN
Binary file not shown.
Reference in New Issue
Block a user