iOS開源項目:FlatUIKit
FlatUIKit是iOS中具有扁平化風(fēng)格的UI(Flat UI)組件。FlatUIKit的設(shè)計靈感來源于Flat UI和Kyle Miller砍濒。FlatUIKit中的組件是通過擴(kuò)展(category)或繼承iOS SDK中已有的UIKit組件來實(shí)現(xiàn)的,因此在程序中使用FlatUIKit非常方便疼阔。
https://github.com/Grouper/FlatUIKit
FUIButton是UIButton的子類顿肺,通過設(shè)置UIButton的一系列屬性來把樣式定義成扁平化的
FUIButton *button = [[FUIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
button.buttonColor = [UIColor turquoiseColor];
button.shadowColor = [UIColor greenSeaColor];
button.shadowHeight = 3.0f;
button.cornerRadius = 3.0f;
button.titleLabel.font = [UIFont boldFlatFontOfSize:16];
[button setTitleColor:[UIColor cloudsColor] forState:UIControlStateNormal];
[button setTitleColor:[UIColor cloudsColor] forState:UIControlStateHighlighted];
[button setTitle:@"button" forState:UIControlStateNormal];
[self.view addSubview:button];
FUISegmentedControl是UISegmentedControl的子類钟鸵,使用上和FUIButton類似,源碼也很簡單撇眯,都是設(shè)置一些屬性报嵌。當(dāng)然屬性的值是很重要的,它們是扁平化設(shè)計的關(guān)鍵熊榛。
NSArray *array = [NSArray arrayWithObjects:@"one",@"two",@"three", nil];
FUISegmentedControl *seg = [[FUISegmentedControl alloc] initWithItems:array];
[seg setFrame:CGRectMake(0, 0, 300, 50)];
seg.selectedFont = [UIFont boldFlatFontOfSize:16];
seg.selectedFontColor = [UIColor cloudsColor];
seg.deselectedFont = [UIFont flatFontOfSize:16];
seg.deselectedFontColor = [UIColor cloudsColor];
seg.selectedColor = [UIColor amethystColor];
seg.deselectedColor = [UIColor silverColor];
seg.dividerColor = [UIColor midnightBlueColor];
seg.cornerRadius = 5.0;
[self.view addSubview:seg];
FUISwitch:
FUISwitch *switchbutton = [[FUISwitch alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
switchbutton.onColor = [UIColor turquoiseColor];
switchbutton.offColor = [UIColor cloudsColor];
switchbutton.onBackgroundColor = [UIColor midnightBlueColor];
switchbutton.offBackgroundColor = [UIColor silverColor];
switchbutton.offLabel.font = [UIFont boldFlatFontOfSize:14];
switchbutton.onLabel.font = [UIFont boldFlatFontOfSize:14];
[self.view addSubview:switchbutton];