• 自定义UISegmentedControl


    在页面中

     1 UIImage *segmentSelected = [[UIImage imageNamed:@"segcontrol_sel.png"]
     2                                 resizableImageWithCapInsets:UIEdgeInsetsMake(0, 15, 0, 15)];
     3     UIImage *segmentUnSelected = [[UIImage imageNamed:@"segcontrol_uns.png"]
     4                                   resizableImageWithCapInsets:UIEdgeInsetsMake(0, 15, 0, 15)];
     5     UIImage *segmentSelectedUnselected = [[UIImage imageNamed:@"segcontrol_sel-uns.png"]
     6                                           resizableImageWithCapInsets:UIEdgeInsetsMake(0, 15, 0, 15)];
     7     UIImage *segmentUnSelectedSelected = [[UIImage imageNamed:@"segcontrol_uns-sel.png"]
     8                                 resizableImageWithCapInsets:UIEdgeInsetsMake(0, 15, 0, 15)];
     9     UIImage *segmentUnSelectedUnSelected = [[UIImage imageNamed:@"segcontrol_uns-uns.png"]
    10                                 resizableImageWithCapInsets:UIEdgeInsetsMake(0, 15, 0, 15)];
    11     
    12     [self.seg setBackgroundImage:segmentUnSelected     // 非选中状态背景图
    13                         forState:UIControlStateNormal
    14                       barMetrics:UIBarMetricsDefault];
    15     [self.seg setBackgroundImage:segmentSelected        // 选中状态背景图
    16                         forState:UIControlStateSelected
    17                       barMetrics:UIBarMetricsDefault];
    18     
    19     [self.seg setDividerImage:segmentUnSelectedUnSelected   // 设置分割部分背景图,二侧都是非选中状态时
    20           forLeftSegmentState:UIControlStateNormal
    21             rightSegmentState:UIControlStateNormal
    22                    barMetrics:UIBarMetricsDefault];
    23     
    24     [self.seg setDividerImage:segmentSelectedUnselected    // 设置分割部分背景图,左边为选中状态,右边为非选中状态时
    25           forLeftSegmentState:UIControlStateSelected
    26             rightSegmentState:UIControlStateNormal
    27                    barMetrics:UIBarMetricsDefault];
    28     
    29     [self.seg setDividerImage:segmentUnSelectedSelected    // 设置分割部分背景图,左边为非选中状态,右边为选中状态
    30           forLeftSegmentState:UIControlStateNormal
    31             rightSegmentState:UIControlStateSelected
    32                    barMetrics:UIBarMetricsDefault];
  • 相关阅读:
    图床_背景
    图床_摘要
    图床_二维码
    在ubuntu上搭建交叉编译环境---arm-none-eabi-gcc
    在ubuntu上搭建交叉编译环境---arm-none-eabi-gcc
    python的sqlalchemy框架
    python的sqlalchemy框架
    python的sqlalchemy框架
    python的sqlalchemy框架
    烂泥:centos6 yum方式升级内核
  • 原文地址:https://www.cnblogs.com/sell/p/2915695.html
Copyright © 2020-2023  润新知