zoukankan      html  css  js  c++  java
  • 去掉segMentedControl的边框和改变选中字体的样式

    一、初始化

    //初始化  并赋值
    UISegmentedControl *segmentControl = [[UISegmentedControl alloc]initWithItems:@[@"头条",@"体育",@"新闻",@"科技",@"娱乐"]];

    //给
    segmentControl一个位置 让它显示

    segmentControl.frame = CGRectMake(0, 60, CGRectGetWidth([UIScreen mainScreen].bounds), 50);

    [self.view addSubview:segmentControl];


    二、清除掉边框颜色  此时会清除掉所有文字

     segmentControl.tintColor = [UIColor clearColor];

    三、先初始化字典 设置字体后  便解决了所有问题

    NSDictionary *dicOne = @{NSFontAttributeName:[UIFont boldSystemFontOfSize:20],NSForegroundColorAttributeName:[UIColor blackColor]};

    四、把字典的值  给segmentControl  注意 setTitleTextAttributes 需要一个字典

    [segmentControl setTitleTextAttributes:dicOne forState:UIControlStateNormal];

    五、选中状态同样

     NSDictionary *dicTwo = @{NSFontAttributeName:[UIFont boldSystemFontOfSize:25],NSForegroundColorAttributeName:[UIColor redColor]};
    
    [segmentControl setTitleTextAttributes:dicTwo forState:UIControlStateSelected];
  • 相关阅读:
    Java的家庭记账本程序(K)
    构建之法阅读笔记01
    Java的家庭记账本程序(J)
    iOS-CALayer实现简单进度条
    iOS-CALayer
    iOS-CAEmitterLayer(粒子效果)
    iOS-OpenGLES 简单渲染
    iOS-CoreImage简单使用
    iOS富文本-NSAttributedString简单封装
    iOS后台运行
  • 原文地址:https://www.cnblogs.com/ios-wanglong/p/5141052.html
Copyright © 2011-2022 走看看