|
@@ -39,20 +39,20 @@ public class ComponentTabs: ComponentBaseXibView {
|
|
|
public override func awakeFromNib() {
|
|
|
super.awakeFromNib()
|
|
|
|
|
|
- self.contendBox.borderWidth = 0
|
|
|
- self.contendBox.fillColor = NSColor.clear
|
|
|
+ contendBox.borderWidth = 0
|
|
|
+ contendBox.fillColor = NSColor.clear
|
|
|
|
|
|
}
|
|
|
|
|
|
//MARK: - public
|
|
|
public func updateItemProperty(_ propertys: [ComponentTabsProperty]) {
|
|
|
- self.propertyArr = propertys
|
|
|
+ propertyArr = propertys
|
|
|
|
|
|
- self.reloadData()
|
|
|
+ reloadData()
|
|
|
}
|
|
|
|
|
|
public func refreshItems() {
|
|
|
- if let subviews = self.contendBox.contentView?.subviews {
|
|
|
+ if let subviews = contendBox.contentView?.subviews {
|
|
|
for view in subviews {
|
|
|
if view is ComponentTabsItem {
|
|
|
(view as! ComponentTabsItem).reloadData()
|
|
@@ -62,7 +62,7 @@ public class ComponentTabs: ComponentBaseXibView {
|
|
|
}
|
|
|
|
|
|
func reloadData() {
|
|
|
- if let subviews = self.contendBox.contentView?.subviews {
|
|
|
+ if let subviews = contendBox.contentView?.subviews {
|
|
|
for view in subviews {
|
|
|
if view is ComponentTabsItem {
|
|
|
view.removeFromSuperview()
|
|
@@ -72,61 +72,61 @@ public class ComponentTabs: ComponentBaseXibView {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if self.propertyArr.count == 0 {
|
|
|
+ if propertyArr.count == 0 {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- let property = self.propertyArr.first
|
|
|
+ let property = propertyArr.first
|
|
|
|
|
|
- self.lineBox.isHidden = true
|
|
|
+ lineBox.isHidden = true
|
|
|
if property?.tabsType == .underline_Fill {
|
|
|
- self.lineBox.isHidden = false
|
|
|
+ lineBox.isHidden = false
|
|
|
if let value = ComponentLibrary.shared.getComponentValueFromKey("colorBorder/divider") {
|
|
|
let currentValue = value as! [String : Any]
|
|
|
- self.lineBox.borderColor = ComponentLibrary.shared.getColor(rgbaDict: currentValue)
|
|
|
+ lineBox.borderColor = ComponentLibrary.shared.getColor(rgbaDict: currentValue)
|
|
|
} else {
|
|
|
- self.lineBox.borderColor = NSColor.clear
|
|
|
+ lineBox.borderColor = NSColor.clear
|
|
|
}
|
|
|
}
|
|
|
|
|
|
DispatchQueue.main.async { [self] in
|
|
|
var itemTotalWidth: CGFloat = 0
|
|
|
- for property in self.propertyArr {
|
|
|
+ for property in propertyArr {
|
|
|
ComponentLibrary.shared.configTabsComponent(properties: property)
|
|
|
itemTotalWidth += property.propertyInfo.viewWidth
|
|
|
}
|
|
|
var itemXValue: CGFloat = 0
|
|
|
var itemGap: CGFloat = 0
|
|
|
if property?.tabsType == .underline_Center {
|
|
|
- itemXValue = (CGRectGetWidth(self.bounds) - itemTotalWidth)/2
|
|
|
+ itemXValue = (CGRectGetWidth(bounds) - itemTotalWidth)/2
|
|
|
} else if property?.tabsType == .underline_Fill {
|
|
|
itemXValue = 0
|
|
|
} else if property?.tabsType == .onlyText {
|
|
|
itemXValue = 0
|
|
|
- itemGap = (CGRectGetWidth(self.bounds) - itemTotalWidth)/(CGFloat(self.propertyArr.count) - 1)
|
|
|
+ itemGap = (CGRectGetWidth(bounds) - itemTotalWidth)/(CGFloat(propertyArr.count) - 1)
|
|
|
}
|
|
|
- for i in 0...self.propertyArr.count - 1 {
|
|
|
- let itemProperty = self.propertyArr[i]
|
|
|
+ for i in 0...propertyArr.count - 1 {
|
|
|
+ let itemProperty = propertyArr[i]
|
|
|
let item = ComponentTabsItem.init()
|
|
|
item.properties = itemProperty
|
|
|
- item.frame = CGRectMake(itemXValue, 0, itemProperty.propertyInfo.viewWidth, self.frame.size.height)
|
|
|
+ item.frame = CGRectMake(itemXValue, 0, itemProperty.propertyInfo.viewWidth, frame.size.height)
|
|
|
if property?.tabsType == .underline_Fill {
|
|
|
- item.frame = CGRectMake(itemXValue, 0, CGRectGetWidth(self.frame)/CGFloat(self.propertyArr.count), self.frame.size.height)
|
|
|
+ item.frame = CGRectMake(itemXValue, 0, CGRectGetWidth(frame)/CGFloat(propertyArr.count), frame.size.height)
|
|
|
} else if property?.tabsType == .onlyText {
|
|
|
- item.frame = CGRectMake(itemXValue, 0, itemProperty.propertyInfo.viewWidth, self.frame.size.height)
|
|
|
+ item.frame = CGRectMake(itemXValue, 0, itemProperty.propertyInfo.viewWidth, frame.size.height)
|
|
|
}
|
|
|
item.tagIndex = i
|
|
|
item.autoresizingMask = [.maxXMargin, .minYMargin, .maxYMargin, .height]
|
|
|
item.setTarget(self, action: #selector(cSelectorItemClicked(_:)))
|
|
|
- self.contendBox.contentView?.addSubview(item)
|
|
|
+ contendBox.contentView?.addSubview(item)
|
|
|
|
|
|
itemXValue += CGRectGetWidth(item.frame)
|
|
|
if property?.tabsType == .onlyText {
|
|
|
- let divider: ComponentDivider = ComponentDivider(frame: CGRectMake(itemXValue+itemGap/2, CGRectGetHeight(self.frame)/2-8, 1, 16))
|
|
|
+ let divider: ComponentDivider = ComponentDivider(frame: CGRectMake(itemXValue+itemGap/2, CGRectGetHeight(frame)/2-8, 1, 16))
|
|
|
let dividerProperty: ComponentDividerProperty = ComponentDividerProperty.init(type: .vertical, dash: false)
|
|
|
divider.properties = dividerProperty
|
|
|
divider.autoresizingMask = [.minXMargin, .maxXMargin, .minYMargin, .maxYMargin]
|
|
|
- self.contendBox.contentView?.addSubview(divider)
|
|
|
+ contendBox.contentView?.addSubview(divider)
|
|
|
|
|
|
itemXValue += itemGap
|
|
|
}
|
|
@@ -137,7 +137,7 @@ public class ComponentTabs: ComponentBaseXibView {
|
|
|
@objc func cSelectorItemClicked(_ item: ComponentTabsItem) {
|
|
|
let property = item.properties
|
|
|
|
|
|
- if let subviews = self.contendBox.contentView?.subviews {
|
|
|
+ if let subviews = contendBox.contentView?.subviews {
|
|
|
for view in subviews {
|
|
|
if view is ComponentTabsItem {
|
|
|
let itemView = view as! ComponentTabsItem
|
|
@@ -149,7 +149,7 @@ public class ComponentTabs: ComponentBaseXibView {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- self.delegate?.componentTabsDidSelected?(self, property)
|
|
|
+ delegate?.componentTabsDidSelected?(self, property)
|
|
|
}
|
|
|
|
|
|
}
|