设置UISegmentControl的文字属性

来源:互联网 发布:网络的利与弊议论文400 编辑:程序博客网 时间:2024/05/17 08:20

以下代码可以设置UISegmentControl的文字属性。


UISegmentedControl *segmentedControl =.................;

        segmentedControl.layer.cornerRadius = 20;

    segmentedControl.clipsToBounds = YES;

    segmentedControl.tintColor =[UIColor redColor]; //设置颜色

    NSDictionary* selectedTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:12],

                                             NSForegroundColorAttributeName: [UIColor whiteColor]};

    [segmentedControl setTitleTextAttributes:selectedTextAttributes forState:UIControlStateSelected];//设置文字属性

    NSDictionary* unselectedTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:12],

                                               NSForegroundColorAttributeName: [UIColor redColor]};

    [segmentedControl setTitleTextAttributes:unselectedTextAttributes forState:UIControlStateNormal];

0 0
原创粉丝点击