相关疑难解决方法(0)

如何从分段控件中删除边框

如何删除分段控件的外边框?我已经将分频器图像设置为我想要的但现在要按照我的应用程序的模拟我需要一个没有外边框的分段控件.

uisegmentedcontrol ios swift

19
推荐指数
3
解决办法
2万
查看次数

如何更改UISegmentcontrol字体和选定的段颜色?

可能重复:
UISegmentedControl选择的段颜色
UISegmentcontrol外观导致问题

您好我想将默认的UISegmentControl字体更改为自定义字体,并将选定的段颜色更改为另一种颜色而不是更暗的颜色.

谢谢

由此

在此输入图像描述

对此

在此输入图像描述

编辑:方案 称为

//更改字体大小,删除阴影,所选文本和背景颜色与正常状态不同

-(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];

    }
Run Code Online (Sandbox Code Playgroud)

iphone xcode uisegmentedcontrol ios

9
推荐指数
1
解决办法
1万
查看次数

在分段控制中转换特定段

有没有办法转换分段控件中包含的特定段的内容?(我必须旋转180度)

不是包含在其中的图像,因为在我的情况下没有一个(我使用过FontAwesome)

示范:

从: 原版的 至: 旋转

transform uisegmentedcontrol swift

7
推荐指数
1
解决办法
478
查看次数

更改所选分段控件的颜色

在我的应用程序中,我能够更改所选分段控件的颜色.但是为另一个索引而不是选定的索引更改颜色.我可以在索引中找到任何错误.

帮我!

我的代码如下:

if([SegmentRound selectedSegmentIndex] == 0)
    {

        UIColor *newSelectedTintColor2 = [UIColor colorWithRed: 98/255.0 green:156/255.0 blue:247/255.0 alpha:1.0];
        [[[SegmentRound subviews] objectAtIndex:0] setTintColor:newSelectedTintColor2];

        UIColor *newSelectedTintColor1 = [UIColor colorWithRed: 54/255.0 green:52/255.0 blue:48/255.0 alpha:1.0];
        [[[SegmentRound subviews] objectAtIndex:1] setTintColor:newSelectedTintColor1];

        UIColor *newSelectedTintColor0 = [UIColor colorWithRed: 54/255.0 green:52/255.0 blue:48/255.0 alpha:1.0];
        [[[SegmentRound subviews] objectAtIndex:2] setTintColor:newSelectedTintColor0];



        FLAGROUND=1;
    }

    if([SegmentRound selectedSegmentIndex] == 1)
    {
        UIColor *newSelectedTintColor1 = [UIColor colorWithRed: 98/255.0 green:156/255.0 blue:247/255.0 alpha:1.0];
        [[[SegmentRound subviews] objectAtIndex:1] setTintColor:newSelectedTintColor1];

        UIColor *newSelectedTintColor0 = [UIColor colorWithRed: 54/255.0 green:52/255.0 blue:48/255.0 alpha:1.0];
        [[[SegmentRound subviews] objectAtIndex:0] setTintColor:newSelectedTintColor0]; …
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c uisegmentedcontrol ios

6
推荐指数
1
解决办法
1万
查看次数

具有自定义颜色的UISegmentedControl:分隔符行错误

它很容易改变UISegmentedControl的颜色.我发现各种解决方案像这样,本网站和最好的这一解决方案.但没有一个是我想要的.

我尝试创建一个简单的东西,它很容易,这是我的代码:(我使用的是iOS 4.2,而不是5.0和xcode 4.0.2)

id segment[3];
UISegmentedControl *segmentedControl;   
- (id)init
{
    NSArray *itens = [NSArray arrayWithObjects: @"Option 1", @"Option 2", @"Option 3", nil];    
    segmentedControl = [[UISegmentedControl alloc] initWithItems:itens];
    [segmentedControl setFrame:CGRectMake(0, 0, 500, 30)];
    [segmentedControl setSegmentedControlStyle:UISegmentedControlStyleBar];
    [segmentedControl addTarget:self 
                    action:@selector(segmentedControl:) 
          forControlEvents:UIControlEventAllEvents];

    switch (type) {
        case type1: [segmentedControl setSelectedSegmentIndex:0]; break;
        case type2: [segmentedControl setSelectedSegmentIndex:1]; break;        
        case type3: [segmentedControl setSelectedSegmentIndex:2]; break;        
    }
    for (int i=0; i<3; i++) {
        //The most important trick to work, have to retain the …
Run Code Online (Sandbox Code Playgroud)

objective-c uisegmentedcontrol ipad ios

5
推荐指数
2
解决办法
9223
查看次数

为分段控件中的选定分段自定义颜色

如何为分段控制中的选定分段自定义/更改颜色?我尝试使用UISegmentedControl中可用的方法选择了段颜色.它与iOS 5及以下版本完美配合,但不适用于iOS 6.任何帮助都表示赞赏.

基本上我希望将所选分段的颜色更改为某种明亮的颜色,以便选择/未选择的段清晰可见.

xcode objective-c background-color uisegmentedcontrol ios6

5
推荐指数
1
解决办法
2535
查看次数

如何在Swift中更改UISegmentedControl的选定段tintColor

我想在Swift 3中更改UISegmentedControl所选段的tintColor。我在Objective-c中搜索了很多答案。
这是我的代码:

class ViewController:UIViewController{

var segment:UISegmentedControl

override func viewDidLoad() {
super.viewDidLoad()

segment.insertSegment(withTitle: "AAA", at: 0, animated: true)
segment.insertSegment(withTitle: "BBB", at: 1, animated: true)
segment.insertSegment(withTitle: "CCC", at: 2, animated: true)

segment.addTarget(self, action: #selector(changeValue), for: .valueChanged)
segment.selectedSegmentIndex = 0

view.addSubview(segment)

}
  func changeValue(sender:AnyObject) {

  //I don't know how to do that change color when segment selected
  // 

}

}
Run Code Online (Sandbox Code Playgroud)

谢谢!

iphone uisegmentedcontrol ios swift

5
推荐指数
3
解决办法
8792
查看次数