Skip to content

Commit

Permalink
Merge pull request banchichen#564 from yJion/master
Browse files Browse the repository at this point in the history
支持定制导航栏返回按钮样式
  • Loading branch information
banchichen authored Aug 31, 2017
2 parents fb7c1e0 + 59ef832 commit 16ad2a1
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 7 deletions.
6 changes: 3 additions & 3 deletions TZImagePickerController.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@
TargetAttributes = {
900E657B1C2BB8D5003D9A9E = {
CreatedOnToolsVersion = 7.2;
DevelopmentTeam = T86X98NCU2;
DevelopmentTeam = 3Q6ZMMAKC2;
ProvisioningStyle = Automatic;
};
900E65941C2BB8D5003D9A9E = {
Expand Down Expand Up @@ -551,7 +551,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = T86X98NCU2;
DEVELOPMENT_TEAM = 3Q6ZMMAKC2;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/TZImagePickerController",
Expand All @@ -572,7 +572,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = T86X98NCU2;
DEVELOPMENT_TEAM = 3Q6ZMMAKC2;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/TZImagePickerController",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@
@property (nonatomic, assign) NSInteger circleCropRadius; ///< 圆形裁剪框半径大小
@property (nonatomic, copy) void (^cropViewSettingBlock)(UIView *cropView); ///< 自定义裁剪框的其他属性

@property (nonatomic, copy) void (^navLeftBarButtonBlock)(UIButton *leftButton); ///< 自定义返回按钮样式及其属性

- (id)showAlertWithTitle:(NSString *)title;
- (void)hideAlertView:(id)alertView;
- (void)showProgressHUD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
@property (nonatomic, assign) BOOL isFirstAppear;
@property (nonatomic, assign) NSInteger columnNumber;
@property (nonatomic, strong) TZAlbumModel *model;

@end


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ - (UIImagePickerController *)imagePickerVc {
}
return _imagePickerVc;
}

- (void)viewDidLoad {
[super viewDidLoad];
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
Expand All @@ -78,6 +77,13 @@ - (void)viewDidLoad {
self.view.backgroundColor = [UIColor whiteColor];
self.navigationItem.title = _model.name;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:tzImagePickerVc.cancelBtnTitleStr style:UIBarButtonItemStylePlain target:tzImagePickerVc action:@selector(cancelButtonClick)];
if (tzImagePickerVc.navLeftBarButtonBlock) {
UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
leftButton.frame = CGRectMake(0, 0, 40, 40);
[leftButton addTarget:self action:@selector(navLeftBarButtonClick) forControlEvents:UIControlEventTouchUpInside];
tzImagePickerVc.navLeftBarButtonBlock(leftButton);
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:leftButton];
}
_showTakePhotoBtn = (([[TZImageManager manager] isCameraRollAlbum:_model.name]) && tzImagePickerVc.allowTakePicture);
// [self resetCachedAssets];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didChangeStatusBarOrientationNotification:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
Expand Down Expand Up @@ -314,7 +320,9 @@ - (void)didChangeStatusBarOrientationNotification:(NSNotification *)noti {
}

#pragma mark - Click Event

-(void)navLeftBarButtonClick{
[self.navigationController popViewControllerAnimated:YES];
}
- (void)previewButtonClick {
TZPhotoPreviewController *photoPreviewVc = [[TZPhotoPreviewController alloc] init];
[self pushPhotoPrevireViewController:photoPreviewVc];
Expand Down
7 changes: 6 additions & 1 deletion TZImagePickerController/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ - (UIImagePickerController *)imagePickerVc {
}
NSDictionary *titleTextAttributes = [tzBarItem titleTextAttributesForState:UIControlStateNormal];
[BarItem setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal];

}
return _imagePickerVc;
}
Expand Down Expand Up @@ -276,7 +277,11 @@ - (void)pushTZImagePickerController {
}];*/

//imagePickerVc.allowPreview = NO;

// 自定义导航栏上的返回按钮
[imagePickerVc setNavLeftBarButtonBlock:^(UIButton *leftButton){
[leftButton setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
[leftButton setImageEdgeInsets:UIEdgeInsetsMake(0, -20, 0, 20)];
}];
imagePickerVc.isStatusBarDefault = NO;
#pragma mark - 到这里为止

Expand Down

0 comments on commit 16ad2a1

Please sign in to comment.