- 一个自定义的 UIButton 类
- iOS 7.0 或更高版本
- tvOS 9.0 或更高版本
- watchOS 2.0 或更高版本
- OS X 10.8 或更高版本
- Xcode 8.0 或更高版本
- 阅读此 Readme 文档
- 阅读 使用部分
- 阅读 CocoaDocs 上的文档
- 尝试示例,从 Github 下载项目或更简单地使用 CocoaPods try
pod try DPAppDoctor
- 查看 安装步骤
- 找出使用 DPAppDoctor 的人并添加您的应用程序到列表中 找出谁在使用 DPAppDoctor
- 如果您需要帮助,请使用 Stack Overflow。 (标签 'DPAppDoctor')
- 如果您想 提出一个一般性问题,请使用 Stack Overflow。
- 如果您 发现了错误,请提交一个问题。
- 如果您 有功能请求,请提交一个问题。
- 如果您 希望贡献代码,请提交一个Pull Request。
如何使用
Objective-C:
#import <CustomImageTextButton.h>
...
- (IBAction)makeButton:(id)sender {
[sectionTitleButton removeFromSuperview];
sectionTitleButton = nil;
CGRect newFram = CGRectMake(30, 30, _widthField.text.floatValue, _heightField.text.floatValue);
UIEdgeInsets newEdgeInsets = UIEdgeInsetsMake(_topField.text.floatValue, _leftField.text.floatValue, _bottomField.text.floatValue, _rightField.text.floatValue);
sectionTitleButton = [DPButton buttonWithFrame:newFram imageTextType:[self getLayoutType] gap:_gapField.text.floatValue normalImage:_currentImage.image heightImage:_currentImage.image selectedImage:_currentImage.image text:_textStrField.text font:[UIFont systemFontOfSize:_textFontField.text.floatValue] textColor:[UIColor blackColor] heightTextColor:[UIColor blackColor] selectedTextColor:[UIColor blackColor] backGroundColor:[UIColor orangeColor] backGroundHightColor:[UIColor orangeColor] backGroundSelectedColor:[UIColor orangeColor] sideEdgeInsets:newEdgeInsets imageSize:CGSizeMake(_imageWidthField.text.floatValue, _imageHeightField.text.floatValue)];
[self.view addSubview:sectionTitleButton];
[sectionTitleButton setBackgroundColor:[UIColor clearColor]];
sectionTitleButton.titleLabel.backgroundColor = [UIColor purpleColor];
sectionTitleButton.imageView.backgroundColor = [UIColor redColor];
}
- (IBAction)updateButton:(id)sender {
if (_widthField.text.floatValue != sectionTitleButton.frame.size.width || _heightField.text.floatValue != sectionTitleButton.frame.size.height) {
sectionTitleButton.frame = CGRectMake(sectionTitleButton.frame.origin.x, sectionTitleButton.frame.origin.y, _widthField.text.floatValue, _heightField.text.floatValue);
}
if ([self getLayoutType] != sectionTitleButton.imageTextButtonType) {
sectionTitleButton.imageTextButtonType = [self getLayoutType];
}
if (_gapField.text.floatValue != sectionTitleButton.imageTextGap) {
sectionTitleButton.imageTextGap = _gapField.text.floatValue;
}
UIEdgeInsets newEdgeInsets = UIEdgeInsetsMake(_topField.text.floatValue, _leftField.text.floatValue, _bottomField.text.floatValue, _rightField.text.floatValue);
if (!UIEdgeInsetsEqualToEdgeInsets(newEdgeInsets, sectionTitleButton.sideEdgeInsets)) {
sectionTitleButton.sideEdgeInsets = newEdgeInsets;
}
if (![sectionTitleButton.deployText isEqualToString:_textStrField.text]) {
sectionTitleButton.deployText = _textStrField.text;
}
if (sectionTitleButton.deployFont != [UIFont systemFontOfSize:_textFontField.text.floatValue]) {
sectionTitleButton.deployFont = [UIFont systemFontOfSize:_textFontField.text.floatValue];
}
if (!CGSizeEqualToSize(sectionTitleButton.imageSize, CGSizeMake(_imageWidthField.text.floatValue, _imageHeightField.text.floatValue))) {
sectionTitleButton.imageSize = CGSizeMake(_imageWidthField.text.floatValue, _imageHeightField.text.floatValue);
}
if (sectionTitleButton.imageName != _currentImage.image) {
sectionTitleButton.imageName = _currentImage.image;
}
if (sectionTitleButton.heightImageName != _currentImage.image) {
sectionTitleButton.heightImageName = _currentImage.image;
}
if (sectionTitleButton.selectedImageName != _currentImage.image) {
sectionTitleButton.selectedImageName = _currentImage.image;
}
}
...
安装
有三种方法可以在项目中使用DPAppDoctor
- 使用CocoaPods
- 使用Carthage
- 通过克隆项目到您的仓库中
使用CocoaPods安装
CocoaPods 是Objective-C的依赖管理器,它自动化并简化了在项目中使用第三方库的过程。有关详细信息,请参阅开始使用部分。
Podfile
platform :ios, '7.0'
pod 'DPAppDoctor', '~> 1.0.5'
如果您使用Swift,请确保添加 use_frameworks!
并将目标设置为iOS 8+
platform :ios, '8.0'
use_frameworks!
构建项目
此时,您的workspace应无错误地构建。如果您遇到问题,请发布到问题区,社区可以帮助您解决这个问题。
协作者
授权
所有源代码均受MIT 许可协议许可。