0

我有UISegmentedControl一个故事板,我有一个出口。在运行时,我有一个方法可以检查操作系统是否小于 iOS7,如果是,我需要将其替换为UISegmentedControl来自 FlatUIKit 的分段控件。该类被调用FUISegmentedControl,它继承自UISegmentedControl. 这是它的初始化方法:

+ (void)initialize {
    if (self == [FUISegmentedControl class]) {
        FUISegmentedControl *appearance = [self appearance];
        [appearance setCornerRadius:5.0f];
        [appearance setSelectedColor:[AppereanceConfiguration defaultTintColor]];
        [appearance setDeselectedColor:[UIColor whiteColor]];
        [appearance setDividerColor:[AppereanceConfiguration defaultTintColor]];
        [appearance setSelectedFont:[AppereanceConfiguration fontLightWithSize:16]];
        [appearance setDeselectedFont:[AppereanceConfiguration fontLightWithSize:16]];
        [appearance setSelectedFontColor:[UIColor whiteColor]];
        [appearance setDeselectedFontColor:[AppereanceConfiguration defaultTintColor]];
    }
}

我不知道如何在运行时UISegmentedControl用这个替换。FUISegmentedControl

这是 FlatUIKit 的 GitHub 链接: FlatUIKit

4

1 回答 1

1

我用代码而不是故事板对这个问题进行了排序。

我用这个检查IOS <7:

#define IS_IOS7 ([[UIDevice currentDevice].systemVersion floatValue] >=7)

我以编程方式而不是故事板添加了我的控件。

if (IS_IOS7)
{
    self.segmCntr = [[UISegmentedControl alloc] initWithFrame:CGRectMake(10, 10, 100, 30)];
}
else
{
    self.segmCntr = [[FUISegmentedControl alloc] initWithFrame:CGRectMake(10, 10, 100, 30)];
}
于 2013-11-22T10:20:55.617 回答