//
// ViewTool.m
// xsism.com
//
// Created by apple on 16/5/10.
// Copyright © 2016年 apple. All rights reserved.
//
#import "ViewTool.h"
@implementation ViewTool
/**
* @author xsism.com
* @brief 添加右导航图标
* @return void
* @param NSString *iconName 图标名称
* @param UIViewController *controller 控制器
* @param SEL selector 方法名
*/
+ (void)addRightBarIconNamed:(NSString *)iconName target:(UIViewController *)controller selector:(SEL)selector
{
UIView *rightBarView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 60, 31)];
UIButton *mapbutton = [UIButton buttonWithType:UIButtonTypeCustom];
[mapbutton setFrame:CGRectMake(30, 5, 30, 30)];
[mapbutton setImage:[UIImage imageNamed:iconName] forState:UIControlStateNormal];
[mapbutton addTarget:controller action:selector forControlEvents:UIControlEventTouchDown];
[rightBarView addSubview:mapbutton];
rightBarView.backgroundColor=[UIColor clearColor];
UIBarButtonItem *rightBtn = [[UIBarButtonItem alloc]initWithCustomView:rightBarView];
controller.navigationItem.rightBarButtonItem = rightBtn;
}
/**
* @author <#xsism.com#>
* @brief <#点击按钮,弹出选择图片框#>
* @return <#BOOL#> <#操作是否成功#>
* @param <#UIButton#> <#*sender#> <#被点击的按钮#>
*/
+ (void)addBackButton:(UIViewController *)controller
{
controller.navigationItem.backBarButtonItem=[[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
}
/**
* @author <#xsism.com#>
* @brief <#点击按钮,弹出选择图片框#>
* @return <#BOOL#> <#操作是否成功#>
* @param <#UIButton#> <#*sender#> <#被点击的按钮#>
*/
+ (void)addTapGuestureOfView:(UIView *)view target:(UIViewController *)controller action:(SEL)action
{
view.userInteractionEnabled = YES;
// 添加tap手势
UITapGestureRecognizer *tapReco = [[UITapGestureRecognizer alloc]initWithTarget:controller action:action];
[view addGestureRecognizer:tapReco];
}
/**
* @author <#xsism.com#>
* @brief <#点击按钮,弹出选择图片框#>
* @return <#BOOL#> <#操作是否成功#>
* @param <#UIButton#> <#*sender#> <#被点击的按钮#>
*/
+ (void)adjustFrameOfViewController:(UIViewController *)controller
{
// view 和 导航 遮盖问题处理
controller.edgesForExtendedLayout = UIRectEdgeNone;
}
/**
* @author <#xsism.com#>
* @brief <#点击按钮,弹出选择图片框#>
* @return <#BOOL#> <#操作是否成功#>
* @param <#UIButton#> <#*sender#> <#被点击的按钮#>
*/
+ (id)loadInstanceFromXIBWithClass:(Class)cls
{
// mainBundel加载xib,扩展名不用写.xib
NSArray *arrayXibObjects = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(cls) owner:nil options:nil];
return arrayXibObjects[0];
}
@end
ViewTool
最新推荐文章于 2019-03-16 14:58:34 发布