UISEGMENTED CONTROL ui modification


UISEGMENTED CONTROL ui modification



I have attached my screen for your reference, what I have to do is I need to make the text inside the segmented control as visible which is bold. when I increase the size of the text inside the segment it increases but I need to increase the boldness of the text.
I need the text color to be white and then text should be bod enough to identify. enter image description here



I have attached the customisation code for your reference



//Customising the segmented control with background color and tint color, font size


segmented_Control.tintColor = UIColor.white
segmented_Control.backgroundColor = UIColor(red: 249/255, green: 8/255, blue: 129/255, alpha: 1)
segmented_Control.layer.cornerRadius = 20
let font = UIFont.systemFont(ofSize: 20)
segmented_Control.setTitleTextAttributes([NSAttributedStringKey.font: font],
for: .normal)





Have you tried UIFont.boldSystemFont(ofSize: 20) ?
– Sandeep Bhandari
Jul 3 at 6:40


UIFont.boldSystemFont(ofSize: 20)





Not related to your question but remove the underscore "_' from the naming in segmented_Control it's really ugly un swift
– zombie
Jul 3 at 6:53


segmented_Control





ok zombie I will remove the underscore.
– Karthick TM
Jul 3 at 6:59





let me try @sandeep Bhandari
– Karthick TM
Jul 3 at 6:59





thanks @SandeepBhandari
– Karthick TM
Jul 3 at 7:05




1 Answer
1



//Customising the segmented control with background color and tint color, font size


segmented_Control.tintColor = UIColor(red: 249/255, green: 8/255, blue: 129/255, alpha: 1)
segmented_Control.backgroundColor = UIColor.white
segmented_Control.layer.cornerRadius = 20
// let font = UIFont.systemFont(ofSize: 20)
let font = UIFont.boldSystemFont(ofSize: 20)
segmented_Control.setTitleTextAttributes([NSAttributedStringKey.font: font],
for: .normal)



now my code is working fine.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

api-platform.com Unable to generate an IRI for the item of type

How to set up datasource with Spring for HikariCP?

PHP contact form sending but not receiving emails