UISegmentedControl selected segment color

Here is the absolute simplest way to change the selected segment to any RGB color. No subclassing or hacks required. segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; UIColor *newTintColor = [UIColor colorWithRed: 251/255.0 green:175/255.0 blue:93/255.0 alpha:1.0]; segmentedControl.tintColor = newTintColor; UIColor *newSelectedTintColor = [UIColor colorWithRed: 0/255.0 green:175/255.0 blue:0/255.0 alpha:1.0]; [[[segmentedControl subviews] objectAtIndex:0] setTintColor:newSelectedTintColor]; This example shows the important steps: Sets … Read more

How to change font color of UISegmentedControl

In iOS 6.0 and above it’s very simple: NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys: [UIFont boldSystemFontOfSize:17], NSFontAttributeName, [UIColor blackColor], NSForegroundColorAttributeName, nil]; [_segmentedControl setTitleTextAttributes:attributes forState:UIControlStateNormal]; NSDictionary *highlightedAttributes = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName]; [_segmentedControl setTitleTextAttributes:highlightedAttributes forState:UIControlStateSelected];

UISegmentedControl below UINavigationbar in iOS 7

It’s a simple effect to accomplish. First, place a segment in a toolbar. Place this toolbar right below the navigation bar. Set the delegate of the toolbar to your view controller, and return UIBarPositionTopAttached in positionForBar:. You can see in the store app, if you perform an interactive pop gesture, that the segment bar does … Read more

How to change the colors of a segment in a UISegmentedControl in iOS 13?

As of iOS 13b3, there is now a selectedSegmentTintColor on UISegmentedControl. 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. To change the color/font of the … Read more

Change font size of UISegmentedControl

I ran into the same issue. This code sets the font size for the entire segmented control. Something similar might work for setting the font type. Note that this is only available for iOS5+ Obj C: UIFont *font = [UIFont boldSystemFontOfSize:12.0f]; NSDictionary *attributes = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName]; [segmentedControl setTitleTextAttributes:attributes forState:UIControlStateNormal]; EDIT: UITextAttributeFont has been deprecated … Read more

Color Tint UIButton Image

As of iOS 7, there is a new method on UIImage to specify the rendering mode. Using the rendering mode UIImageRenderingModeAlwaysTemplate will allow the image color to be controlled by the button’s tint color. Objective-C UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; UIImage *image = [[UIImage imageNamed:@”image_name”] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; [button setImage:image forState:UIControlStateNormal]; button.tintColor = [UIColor redColor]; Swift let … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)