Commit e0a4eda9 authored by yuzheng.tz's avatar yuzheng.tz

适配iOS6

parent 9ec606b1
...@@ -233,6 +233,7 @@ ...@@ -233,6 +233,7 @@
@interface NSString (TzExtension) @interface NSString (TzExtension)
- (BOOL)tz_containsString:(NSString *)string; - (BOOL)tz_containsString:(NSString *)string;
- (CGSize)tz_calculateSizeWithAttributes:(NSDictionary *)attributes maxSize:(CGSize)maxSize;
@end @end
......
...@@ -62,7 +62,9 @@ ...@@ -62,7 +62,9 @@
- (void)setNaviBgColor:(UIColor *)naviBgColor { - (void)setNaviBgColor:(UIColor *)naviBgColor {
_naviBgColor = naviBgColor; _naviBgColor = naviBgColor;
if (iOS7Later) {
self.navigationBar.barTintColor = naviBgColor; self.navigationBar.barTintColor = naviBgColor;
}
} }
- (void)setNaviTitleColor:(UIColor *)naviTitleColor { - (void)setNaviTitleColor:(UIColor *)naviTitleColor {
...@@ -708,6 +710,19 @@ ...@@ -708,6 +710,19 @@
} }
} }
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (CGSize)tz_calculateSizeWithAttributes:(NSDictionary *)attributes maxSize:(CGSize)maxSize {
CGSize size;
if (iOS7Later) {
size = [self boundingRectWithSize:maxSize options:NSStringDrawingUsesFontLeading attributes:attributes context:nil].size;
} else {
size = [self sizeWithFont:attributes[NSFontAttributeName] constrainedToSize:maxSize];
}
return size;
}
#pragma clang diagnostic pop
@end @end
......
...@@ -54,7 +54,9 @@ static CGFloat itemMargin = 5; ...@@ -54,7 +54,9 @@ static CGFloat itemMargin = 5;
_imagePickerVc = [[UIImagePickerController alloc] init]; _imagePickerVc = [[UIImagePickerController alloc] init];
_imagePickerVc.delegate = self; _imagePickerVc.delegate = self;
// set appearance / 改变相册选择页的导航栏外观 // set appearance / 改变相册选择页的导航栏外观
if (iOS7Later) {
_imagePickerVc.navigationBar.barTintColor = self.navigationController.navigationBar.barTintColor; _imagePickerVc.navigationBar.barTintColor = self.navigationController.navigationBar.barTintColor;
}
_imagePickerVc.navigationBar.tintColor = self.navigationController.navigationBar.tintColor; _imagePickerVc.navigationBar.tintColor = self.navigationController.navigationBar.tintColor;
UIBarButtonItem *tzBarItem, *BarItem; UIBarButtonItem *tzBarItem, *BarItem;
if (iOS9Later) { if (iOS9Later) {
...@@ -294,14 +296,14 @@ static CGFloat itemMargin = 5; ...@@ -294,14 +296,14 @@ static CGFloat itemMargin = 5;
toolBarTop = self.view.tz_height - toolBarHeight - navigationHeight; toolBarTop = self.view.tz_height - toolBarHeight - navigationHeight;
} }
_bottomToolBar.frame = CGRectMake(0, toolBarTop, self.view.tz_width, toolBarHeight); _bottomToolBar.frame = CGRectMake(0, toolBarTop, self.view.tz_width, toolBarHeight);
CGFloat previewWidth = [tzImagePickerVc.previewBtnTitleStr boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]} context:nil].size.width + 2; CGFloat previewWidth = [tzImagePickerVc.previewBtnTitleStr tz_calculateSizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]} maxSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)].width + 2;
if (!tzImagePickerVc.allowPreview) { if (!tzImagePickerVc.allowPreview) {
previewWidth = 0.0; previewWidth = 0.0;
} }
_previewButton.frame = CGRectMake(10, 3, previewWidth, 44); _previewButton.frame = CGRectMake(10, 3, previewWidth, 44);
_previewButton.tz_width = !tzImagePickerVc.showSelectBtn ? 0 : previewWidth; _previewButton.tz_width = !tzImagePickerVc.showSelectBtn ? 0 : previewWidth;
if (tzImagePickerVc.allowPickingOriginalPhoto) { if (tzImagePickerVc.allowPickingOriginalPhoto) {
CGFloat fullImageWidth = [tzImagePickerVc.fullImageBtnTitleStr boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size.width; CGFloat fullImageWidth = [tzImagePickerVc.fullImageBtnTitleStr tz_calculateSizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} maxSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)].width;
_originalPhotoButton.frame = CGRectMake(CGRectGetMaxX(_previewButton.frame), 0, fullImageWidth + 56, 50); _originalPhotoButton.frame = CGRectMake(CGRectGetMaxX(_previewButton.frame), 0, fullImageWidth + 56, 50);
_originalPhotoLabel.frame = CGRectMake(fullImageWidth + 46, 0, 80, 50); _originalPhotoLabel.frame = CGRectMake(fullImageWidth + 46, 0, 80, 50);
} }
......
...@@ -241,7 +241,7 @@ ...@@ -241,7 +241,7 @@
CGFloat toolBarTop = self.view.tz_height - toolBarHeight; CGFloat toolBarTop = self.view.tz_height - toolBarHeight;
_toolBar.frame = CGRectMake(0, toolBarTop, self.view.tz_width, toolBarHeight); _toolBar.frame = CGRectMake(0, toolBarTop, self.view.tz_width, toolBarHeight);
if (_tzImagePickerVc.allowPickingOriginalPhoto) { if (_tzImagePickerVc.allowPickingOriginalPhoto) {
CGFloat fullImageWidth = [_tzImagePickerVc.fullImageBtnTitleStr boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size.width; CGFloat fullImageWidth = [_tzImagePickerVc.fullImageBtnTitleStr tz_calculateSizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} maxSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)].width;
_originalPhotoButton.frame = CGRectMake(0, 0, fullImageWidth + 56, 44); _originalPhotoButton.frame = CGRectMake(0, 0, fullImageWidth + 56, 44);
_originalPhotoLabel.frame = CGRectMake(fullImageWidth + 42, 0, 80, 44); _originalPhotoLabel.frame = CGRectMake(fullImageWidth + 42, 0, 80, 44);
} }
......
...@@ -57,7 +57,9 @@ ...@@ -57,7 +57,9 @@
_imagePickerVc = [[UIImagePickerController alloc] init]; _imagePickerVc = [[UIImagePickerController alloc] init];
_imagePickerVc.delegate = self; _imagePickerVc.delegate = self;
// set appearance / 改变相册选择页的导航栏外观 // set appearance / 改变相册选择页的导航栏外观
if (iOS7Later) {
_imagePickerVc.navigationBar.barTintColor = self.navigationController.navigationBar.barTintColor; _imagePickerVc.navigationBar.barTintColor = self.navigationController.navigationBar.barTintColor;
}
_imagePickerVc.navigationBar.tintColor = self.navigationController.navigationBar.tintColor; _imagePickerVc.navigationBar.tintColor = self.navigationController.navigationBar.tintColor;
UIBarButtonItem *tzBarItem, *BarItem; UIBarButtonItem *tzBarItem, *BarItem;
if (iOS9Later) { if (iOS9Later) {
...@@ -236,7 +238,9 @@ ...@@ -236,7 +238,9 @@
// 2. Set the appearance // 2. Set the appearance
// 2. 在这里设置imagePickerVc的外观 // 2. 在这里设置imagePickerVc的外观
// if (iOS7Later) {
// imagePickerVc.navigationBar.barTintColor = [UIColor greenColor]; // imagePickerVc.navigationBar.barTintColor = [UIColor greenColor];
// }
// imagePickerVc.oKButtonTitleColorDisabled = [UIColor lightGrayColor]; // imagePickerVc.oKButtonTitleColorDisabled = [UIColor lightGrayColor];
// imagePickerVc.oKButtonTitleColorNormal = [UIColor greenColor]; // imagePickerVc.oKButtonTitleColorNormal = [UIColor greenColor];
// imagePickerVc.navigationBar.translucent = NO; // imagePickerVc.navigationBar.translucent = NO;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment