The UICustomizeKit 扩展标准 UIKit 组件以创建令人惊叹的控件。我发现有很多好的 UI 套件为 iOS 而来,但没有一个是完整实现控件或易于在主题之外定制的。UICustomizeKit 的目标是让您轻松自定义所有控件,以最小努力创建出精彩的样式。现在提供了扁平化(Flat)和 Bootstrap 控件套件(希望您能贡献更多!)那些仓库可以在以下找到:
https://github.com/daltoniam/FlatUIKit
https://github.com/daltoniam/BootstrapUIKit
需要 CoreGraphics 框架、quartz 框架和 Accelerate 框架(用于模糊效果)。
按钮示例
- (void)viewDidLoad
{
[super viewDidLoad];
// silly button example, to show off every property in BaseButton.
NSArray *colors = @[[UIColor colorWithWhite:0.9 alpha:1], [UIColor colorWithWhite:0.7 alpha:1]];
CGRect rect = { .origin.x = 20.0, .origin.y = 70.0, .size.width = 44.0, .size.height = 24.0 };
BaseButton *button = [[BaseButton alloc] initWithFrame:rect];
button.colors = colors;
CGFloat *colorLocs = (CGFloat*)malloc(sizeof(CGFloat) * 2);
colorLocs[0] = 0.0f;
colorLocs[1] = 1.0f;
button.colorRange = colorLocs;
button.selectedColors = colors;
button.selectedRange = colorLocs;
button.disabledColors = @[[UIColor lightGrayColor]];
button.borderWidth = 1.0f;
button.borderColor = [UIColor colorWithWhite:0.7 alpha:1];
button.isBackButton = YES;
button.corners = 5.0;
// a more modern button.
CGRect rect2 = { .origin.x = 20.0, .origin.y = 110.0, .size.width = 132.0, .size.height = 44.0 };
BaseButton *modernButton = [[BaseButton alloc] initWithFrame:rect2];
modernButton.colors = @[[UIColor colorWithRed:72.0f/255 green:153.0f/255 blue:251.0f/255 alpha:1]];
modernButton.selectedColors = @[[UIColor blueColor]];
modernButton.disabledColors = @[[UIColor lightGrayColor]];
[modernButton setTitle:@"Hi There" forState:UIControlStateNormal];
[modernButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
modernButton.rounding = 10.0f;
modernButton.corners = UIRectCornerAllCorners;
CGFloat *range = (CGFloat*)malloc(sizeof(CGFloat) * 2);
colorLocs[0] = 0.0f;
colorLocs[1] = 1.0f;
modernButton.colorRange = range;
[self.view addSubview:button];
[self.view addSubview:modernButton];
}
ProgressView 示例
- (void)viewDidLoad
{
[super viewDidLoad];
// progress view example.
NSArray *colors = @[[UIColor colorWithRed:72.0f/255 green:153.0f/255 blue:251.0f/255 alpha:1]];
CGRect rect = { .origin.x = 20.0, .origin.y = 80.0, .size.width = 182.0, .size.height = 44.0 };
BaseProgressView *progressView = [[BaseProgressView alloc] initWithFrame:rect];
progressView.colors = colors;
CGFloat *colorLocs = (CGFloat*)malloc(sizeof(CGFloat) * 2);
colorLocs[0] = 0.0f;
colorLocs[1] = 1.0f;
progressView.colorRange = colorLocs;
progressView.trackColors = @[[UIColor lightGrayColor]];
progressView.trackRange = colorLocs;
progressView.borderWidth = 1;
progressView.borderColor = [UIColor colorWithWhite:0.4 alpha:1];
progressView.rounding = 8;
progressView.corners = UIRectCornerAllCorners;
[progressView setProgress:0.75 animated:YES];
progressView.backgroundColor = [UIColor clearColor];
[self.view addSubview:progressView];
}
Slider 示例
- (void)viewDidLoad
{
[super viewDidLoad];
//slider example
NSArray *colors = @[[UIColor redColor]];
CGRect rect = { .origin.x = 20.0, .origin.y = 80.0, .size.width = 182.0, .size.height = 44.0 };
BaseSlider *slider = [[BaseSlider alloc] initWithFrame:rect];
slider.colors = colors;
CGFloat *colorLocs = (CGFloat*)malloc(sizeof(CGFloat) * 2);
colorLocs[0] = 0.0f;
colorLocs[1] = 1.0f;
slider.colorRange = colorLocs;
slider.trackColors = @[[UIColor lightGrayColor]];
slider.trackRange = colorLocs;
slider.thumbColors = @[[UIColor blackColor]];
slider.thumbRange = colorLocs;
slider.thumbSelectedColors = @[[UIColor yellowColor]];
slider.thumbSelectedRange = colorLocs;
[self.view addSubview:slider];
}
Switch 示例
- (void)viewDidLoad
{
[super viewDidLoad];
//switch example
CGRect rect = { .origin.x = 20.0, .origin.y = 80.0};
BaseSwitchView *sw = [[BaseSwitchView alloc] initWithFrame:rect];
sw.onText = @"Yes";
sw.offText = @"No";
sw.backgroundColor = [UIColor lightGrayColor];
sw.onBackgroundColor = [UIColor blackColor];
sw.onColor = [UIColor blackColor];
sw.offBackgroundColor = [UIColor redColor];
sw.offColor = [UIColor redColor];
[sw setOn:YES animated:NO];
}
TextField 示例
- (void)viewDidLoad
{
[super viewDidLoad];
//textfield example
CGRect rect = { .origin.x = 20.0, .origin.y = 80.0, .size.width = 182.0, .size.height = 44.0 };
BaseTextField *textField = [[BaseTextField alloc] initWithFrame:rect];
textField.borderWidth = 1;
textField.mainTextColor = [UIColor redColor];
textField.borderColor = [UIColor colorWithWhite:0.8 alpha:1];
textField.bodyColor = [UIColor colorWithWhite:0.9 alpha:1];
}
TextView 示例
- (void)viewDidLoad
{
[super viewDidLoad];
//textView example
CGRect rect = { .origin.x = 20.0, .origin.y = 80.0, .size.width = 182.0, .size.height = 44.0 };
BaseTextView *textView = [[BaseTextView alloc] initWithFrame:rect];
textView.mainTextColor = [UIColor redColor];
textView.borderWidth = 1;
textView.borderColor = [UIColor colorWithWhite:0.9 alpha:1];
[self.view addSubview:textView];
}
RadialProgressView 示例
- (void)viewDidLoad
{
[super viewDidLoad];
//radial progress view example
CGRect rect = { .origin.x = 20.0, .origin.y = 80.0, .size.width = 40, .size.height = 40 };
BaseRadialProgressView *view = [[BaseRadialProgressView alloc] initWithFrame:rect];
view.borderColor = [UIColor greenColor];
[view setProgress:0.8 animated:YES];
[self.view addSubview:view];
}
ActivityView 示例
- (void)viewDidLoad
{
[super viewDidLoad];
//ActivityView example
CGRect rect = { .origin.x = 20.0, .origin.y = 80.0, .size.width = 40, .size.height = 40 };
BaseActivityView *view = [[BaseActivityView alloc] initWithFrame:rect];
[self.view addSubview:view];
[view startAnimating];
[self.view addSubview:view];
}
此框架需要 iOS 6 或更高版本。
UICustomizeKit 采用 Apache 许可证。
安装 UICustomizeKit 的推荐方法是使用 CocoaPods 软件包管理器,因为它提供灵活的依赖项管理和简单的安装过程。
通过 CocoaPods(尚未完成,还需要添加此部分)
如果尚不可用,请安装 CocoaPods。
$ [sudo] gem install cocoapods
$ pod setup
切换到您的 Xcode 项目的目录,创建并编辑您的 Podfile 并添加 RestKit
$ cd /path/to/MyProject
$ touch Podfile
$ edit Podfile
platform :ios, '5.0'
pod 'UICustomizeKit'
将项目安装到您的项目中
$ pod install
使用 .xcworkspace 文件打开您的项目(而不是常规的项目文件)