Closed VigneshVV closed 4 years ago
@VigneshVV Which segment is selected in your screenshot.
If white is selected, then following workaround might work.
textSquareSegmentedControl.textColor = .white
textSquareSegmentedControl.selectedTextColor = UIColor(red: 63/255, green: 172/255, blue: 252/255, alpha: 1)
textSquareSegmentedControl.thumbViewColor = .white
textSquareSegmentedControl.segmentedBackGroundColor = UIColor(red: 63/255, green: 172/255, blue: 252/255, alpha: 1)
textSquareSegmentedControl.backgroundColor = .white
textSquareSegmentedControl.customBorderWidth = 2
If its other way around then there might be issue an assigning border color
Thanks for your response. In above case Blue colour is selected. my segment baground color should be white. selected thumbnail should be blue. Border color should be blue.
Custom border color and width properties are not working for me.
@VigneshVV There is the bug while assigning the border color in the framework. I have a fix, I will be sending out the update soon. Lookout for the next release. Thanks for choosing the framework.
@lokeshub Thanks for stepping up and try to provide the workaround.
The issue is; the border is not being set in layout view of the framework. add the lines to the method below in MASegmentedControl.swift
self.layer.borderWidth = self.customBorderWidth
self.layer.borderColor = self.customBorderColor.cgColor
//3 all UI layout based on frames must be called on layoutSubviews
override public func layoutSubviews() {
super.layoutSubviews()
layer.cornerRadius = roundedControl ? frame.height / 2 : 1.0
self.backgroundColor = self.segmentedBackGroundColor
self.layer.borderWidth = self.customBorderWidth
self.layer.borderColor = self.customBorderColor.cgColor
setThumbView()
//if fillEqually is not true the layout is not in stackview and its set based on frames
guard !fillEqually else { return }
for (index, btn) in self.buttons.enumerated() {
btn.frame = setFrameForButtonAt(index: index)
}
}
Since you are modifying the framework; you need to clean and build for this to take effect.
@scottiesan thanks for pointing out.
I totally did the blunder here by writing and not setting the correct color to the border.
self.layer.borderColor = self.segmentedBackGroundColor.cgColor
This is available in 0.0.5
This is available in 0.0.5
Thanks! I love this control!
Hello, How can i set border like below image?