Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segment Border. #2

Closed
VigneshVV opened this issue Mar 13, 2020 · 7 comments
Closed

Segment Border. #2

VigneshVV opened this issue Mar 13, 2020 · 7 comments
Labels

Comments

@VigneshVV
Copy link

Hello,
How can i set border like below image?

Screenshot 2020-03-13 at 7 49 14 PM

@alokc83 alokc83 added the HowTo label Mar 15, 2020
@lokeshub
Copy link

lokeshub commented Mar 15, 2020

@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

@VigneshVV
Copy link
Author

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.

@alokc83
Copy link
Owner

alokc83 commented Mar 16, 2020

@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.

@scottiesan
Copy link

scottiesan commented Jun 5, 2020

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.

@alokc83
Copy link
Owner

alokc83 commented Jun 22, 2020

@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

alokc83 added a commit that referenced this issue Jun 22, 2020
@alokc83
Copy link
Owner

alokc83 commented Jun 22, 2020

This is available in 0.0.5

@alokc83 alokc83 closed this as completed Jun 22, 2020
@scottiesan
Copy link

This is available in 0.0.5

Thanks! I love this control!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants