如何更改UISegmentcontrol字体和选定的段颜色? [英] How to change UISegmentcontrol font and selected segment colour?
本文介绍了如何更改UISegmentcontrol字体和选定的段颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
Possible Duplicate:
UISegmentedControl selected segment color
UISegmentcontrol appearances causing issuesHi i will like to change the default UISegmentControl font to a custom font and change the selected segment color to another color instead of a darker color.
thanks
from this
to this
EDIT:Solution called
//change font size, remove shadow, selected text & background color are different from normal state
-(void)defineSegmentControlStyle { //normal segment NSDictionary *normalAttributes = [NSDictionary dictionaryWithObjectsAndKeys: [UIFont fontWithName:@"Rok" size:20.0],UITextAttributeFont, [UIColor colorWithRed:75.0/255.0 green:75.0/255.0 blue:75.0/255.0 alpha:1.0], UITextAttributeTextColor, [UIColor clearColor], UITextAttributeTextShadowColor, [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset, nil];//[NSDictionary dictionaryWithObject: [UIColor redColor]forKey:UITextAttributeTextColor]; [infoSegment setTitleTextAttributes:normalAttributes forState:UIControlStateNormal]; NSDictionary *selectedAttributes = [NSDictionary dictionaryWithObjectsAndKeys: [UIFont fontWithName:@"Rok" size:20.0],UITextAttributeFont, [UIColor whiteColor], UITextAttributeTextColor, [UIColor clearColor], UITextAttributeTextShadowColor, [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset, nil] ;//[NSDictionary dictionaryWithObject: [UIColor redColor]forKey:UITextAttributeTextColor]; [infoSegment setTitleTextAttributes:selectedAttributes forState:UIControlStateSelected]; }
解决方案You may want to check out this: http://idevrecipes.com/2010/12/11/custom-segmented-controls/
这篇关于如何更改UISegmentcontrol字体和选定的段颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文