Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom UI segmented control

I'm wondering if in IOS is possible to customize segmented control like the attached image. I have tried to change buttons image, but the segmented control container is still visible under the customized buttons. I observed that the segmented buttons title disappears if you add button image. Custom button images must include title?

Many thanks

enter image description here

like image 642
theomen Avatar asked Apr 24 '12 17:04

theomen


People also ask

How do I create a custom segmented control in Swift?

First, we need to create our variable:Three variables to customize our view with a default value. Now we need to put our buttons in view but we have an array and this can be unlimited. The best to do this is create a Horizontal Stack View. Stack View makes the subViews with equal spacing without using any constraint.

What is segmented control?

A segmented control is a linear set of two or more segments, each of which functions as a button. Within a segmented control, all segments are usually equal in width. Like buttons, segments can contain text or images. Segments can also have text labels beneath them (or beneath the control as a whole).

What is segment control in Swift?

“Segment control is a set of two or more segments, which is used to perform multiple tasks on the same screen. Segment working same as a button.”

How do I change the color of a segment in Swift?

To change the overall color of the segmented control use its backgroundColor . To change the color of the selected segment use selectedSegmentTintColor . To change the color/font of the unselected segment titles, use setTitleTextAttributes with a state of . normal / UIControlStateNormal .


1 Answers

Just roll your own. Make three UIButtons with two images for each state and write logic to allow only one of them to be selected.

like image 162
LJ Wilson Avatar answered Sep 22 '22 12:09

LJ Wilson