约定:为了减少宏定义数量,常用公共宏定义模式,如果当前私有块宏定义没有找到,请去上个模块,或公共模块寻找相关宏定义
比如三十模块里面的宏定义,很多都定义在二十九模块里面。
2017年2月8日
//一些简写约定
/*
lItem = leftItem rItem = rightItem lFlap = leftFlap rFlap = rightFlap uFlap = upFlap dFlap = downFlap
rBtn = rightBtn lTilte = leftTitle uTitle = upTitle rContent = rightContent dContent = downContent
lImage = leftImage rChoiceBtn = rightChoiceBtn uMargin = upMargin dMargin = downMargin
/
一 01分辨率【暂时没用】
//基础规范1.0分辨率是按照iphone5的分辨率作为设计标准(@2x 6401136)
公共模块宏定义:
//公共
#define HHBWIDTH [UIScreen mainScreen].bounds.size.width
#define HHBHEIGHT [UIScreen mainScreen].bounds.size.height
#define line_height 0.5
#define mainBtn_font fontsize_T2
#define PingFangSC_Regular @"PingFangSC-Regular" //默认字体
#define PingFangSC_Light @"PingFangSC-Light" //默认字体
#define menuBarView_height 49 //底部menu bar 高度
#define border_line_color ([HuConfigration uiColorFromString:@"#E5E5E5"])
二 //02主色调
//此规范以举例下面的蓝色为主色调,其他各个app可自行选择合适的颜色
宏定义如下:
#define blue_color ([HuConfigration uiColorFromString:@"#50ABF2"]) //蓝色系 用于护理,护士
#define pink_color ([HuConfigration uiColorFromString:@"#FF7373"]) //粉色系 用于儿保,妇幼,婴儿,急诊
#define deep_blue_color ([HuConfigration uiColorFromString:@"#4D65C4"]) //深蓝色(偏紫色)用于睡眠,医院
#define green_color ([HuConfigration uiColorFromString:@"#65D566"]) //绿色系 用于医院,呵护相关婴儿,社区养老
三 03字体
//字体应用规范,定义字体尺寸,颜色,选用字体等细节。在具体的UI中,参考字体的规范选择合适的字体
//注H5规范字体使用系统默认字体,ios默认 中文字体:苹方(PingFangSC)英文字体:SF UI Display 数字字体: Avenir Next LT-pro;安卓使用黑体
3.1直接使用如下宏就可以获得对应的字体(已经包含plus尺寸字体的自适应了):
//用于titlebar,主次按钮的字体大小
#define fontsize_T1 ([HuConfigration systemFontOfPixelSize:36]) //36px
//一级标题,暗提示,产品名称,警示按钮文字,通栏按钮文字,情感化空白页面说明文字
#define fontsize_T2 ([HuConfigration systemFontOfPixelSize:32]) //32px
//卡片标题,标题栏两边按钮位子,正文内容,二级tab,副标题和说明提示
#define fontsize_T3 ([HuConfigration systemFontOfPixelSize:28]) //28px
//图表辅助文字,备注文字,线框小按钮文字
#define fontsize_T4 ([HuConfigration systemFontOfPixelSize:24]) //24px
//底部标签文字,辅助文字里特别不重要的建议使用20px
#define fontsize_T5 ([HuConfigration systemFontOfPixelSize:20]) //20px
//font_face @"PingFangSC-Light"
#define fontsize_T1_light ([HuConfigration systemFontOfPixelSize:36 withFontFace:PingFangSC_Light]) //36px
#define fontsize_T2_light ([HuConfigration systemFontOfPixelSize:32 withFontFace:PingFangSC_Light]) //32px
#define fontsize_T3_light ([HuConfigration systemFontOfPixelSize:28 withFontFace:PingFangSC_Light]) //28px
#define fontsize_T4_light ([HuConfigration systemFontOfPixelSize:24 withFontFace:PingFangSC_Light]) //24px
#define fontsize_T5_light ([HuConfigration systemFontOfPixelSize:20 withFontFace:PingFangSC_Light]) //20px
其中字体自适应代码
#define IS_SCREEN_55_INCH ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)
#define kFontScale [[UIScreen mainScreen] bounds].size.width / 375.0
//字体适配规则,除了5.5寸的其他都是标准的, 适配规则 标准(5.5寸):20(38),24(44),28(48),32(52),36(54)
+ (UIFont *)systemFontOfPixelSize:(NSUInteger)pxSize
{
return [HuConfigration systemFontOfPixelSize:pxSize withFontFace:@""];
}
+ (UIFont *)systemFontOfPixelSize:(NSUInteger)pxSize withFontFace:(NSString*)fontFace
{
if ([fontFace length] <= 0) {
fontFace = PingFangSC_Regular;
}
CGFloat tmp = pxSize;
if(IS_SCREEN_55_INCH){
if (pxSize == 20) {
tmp = 38;
}else if (pxSize == 24){
tmp = 44;
}else if (pxSize == 28){
tmp = 48;
}else if (pxSize == 32){
tmp = 52;
}else if (pxSize == 36){
tmp = 54;
}else{
tmp = kFontScale * pxSize;
}
}
CGFloat fontSize = tmp / 2.0;
return [UIFont fontWithName:fontFace size:fontSize];
}
3.2直接使用如下宏定义,就可以获得对应颜色值
//字体颜色
#define fontcolor_C1 ([HuConfigration uiColorFromString:@"#ffffff"]) //仅用于标题,按钮和深色背景中
#define fontcolor_C2 ([HuConfigration uiColorFromString:@"#333333"]) //标题,标签,输入内容,正文文本
#define fontcolor_C3 ([HuConfigration uiColorFromString:@"#666666"]) //tab未选文字,次要辅助文本
#define fontcolor_C4 ([HuConfigration uiColorFromString:@"#a5a5a5"]) //说明,备注,辅助文本
#define fontcolor_C5 ([HuConfigration uiColorFromString:@"#50ABF2"]) //可点链接色,tab已选颜色,主色调
#define fontcolor_C6 ([HuConfigration uiColorFromString:@"#FF8208"]) //重点提示色,可根据业务自行使用
#define fontcolor_C7 ([HuConfigration uiColorFromString:@"#FF513C"]) //用于警示,错误,高危危险状态
四、导航栏 【暂无使用,用系统自带的】
常规导航栏
4.1 (04)常规导航栏-深底色
//04导航栏-深底色【暂无使用,用系统自带的】
#define navi_deep_left_xPos 15 //返回按钮距离最左边的间距
#define navi_deep_left_rMargin 5 //返回按钮与文字的间距
#define navi_deep_btns_margin 8 //返回文字与其它item的间距
#define navi_deep_title_font fontsize_T1_light //导航条标题文字的字号
#define navi_deep_title_color fontcolor_C1 //导航条标题文字颜色
#define navi_deep_rItem_rMargin 15 //导航条上右边item距离最右边的间距
#define navi_deep_rItem_dMargin 13 //导航条上右边item距离导航栏底部间距
#define navi_deep_rItem_width 18 //item的宽
#define navi_deep_rItem_height 18 //item的高
#define navi_deep_imgBtn_Margin 15 //右边图像按钮间距离
五导航栏-浅底色(对应文档其实是06项)【暂时没有用到】
(06)常规导航栏-浅底色
//06.1 常规导航栏使用场景: item之间的间距和大小都与深底色(04)的一样
#define navi_light_leftBtn_titleColor fontcolor_C5 //返回按钮上文字的颜色
#define navi_light_leftBtn_font fontsize_T3_light //返回按钮文字的大小
#define navi_light_title_font fontsize_T1_light //常规导航条标题文字的字号
#define navi_light_title_color fontcolor_C2 //常规导航条标题文字颜色
#define navi_light_rItem_fillColor fontcolor_C5
六导航栏-拓展导航栏(对应文档是05项,和06项的后半部分)【已将分段组件做成控件】
拓展导航栏-深底色
拓展导航栏-浅底色
用法:
初始化的时候传入大小,
当是深底色的时候将第二个参数的bool值设置为NO;
当是浅底色的时候bool值为YES
// HuNavigationBarExpand.h
#import <Foundation/Foundation.h>
@protocol HuNavigationBarExpandDelegate <NSObject>
/**
segment点击的事件
*/
- (void)segmentValueChange:(UISegmentedControl *)segmnet;
@end
@interface HuNavigationBarExpand : NSObject
@property (nonatomic, assign)id<HuNavigationBarExpandDelegate>delegate;
/**
拓展导航栏:根据个数的多少设置宽度
@param array 传入分段的标题
@param isLightCo 导航栏上是浅色底(白色)还是深底色
@return
*/
- (UIView *)segmentViewWithArray:(NSArray *)array isLightColor:(BOOL)isLightCo;
@end
// HuNavigationBarExpand.m
#import "HuNavigationBarExpand.h"
#define kBlueSelectColor [HuConfigration uiColorFromString:fontcolor_C5]
#define twoOrThreeItems_segmentControl_width 150
#define fourItems_segmentControl_width 220
#define segmentControl_height 24
@implementation HuNavigationBarExpand
- (UIView *)segmentViewWithArray:(NSArray *)array isLightColor:(BOOL)isLightCo{
UISegmentedControl *segment = [[UISegmentedControl alloc]initWithItems:array];
NSInteger count = array.count;
CGFloat width = 0.0;
switch (count) {
case 2:
width = twoOrThreeItems_segmentControl_width;
break;
case 3:
width = twoOrThreeItems_segmentControl_width;
break;
case 4:
width = fourItems_segmentControl_width;
break;
default:
break;
}
CGFloat x = (HHBWIDTH - width )/2;
segment.frame = CGRectMake(x, 10, width, segmentControl_height);
UIColor *normalColor;
UIColor *selectColor;
//如果是浅色底
if (isLightCo == YES) {
segment.tintColor = kBlueSelectColor;
normalColor = kBlueSelectColor;
selectColor = [UIColor whiteColor];
}else{
segment.tintColor = [UIColor whiteColor];
normalColor = [UIColor whiteColor];
selectColor = kBlueSelectColor;
}
[segment addTarget:self action:@selector(segmentClick:) forControlEvents:UIControlEventValueChanged];
segment.selectedSegmentIndex = 0;
//设置字体样式:
NSDictionary *dict = @{NSFontAttributeName:fontsize_T4,NSForegroundColorAttributeName:normalColor};
[segment setTitleTextAttributes:dict forState:UIControlStateNormal];
[segment setTitleTextAttributes:@{NSFontAttributeName:fontsize_T4,NSForegroundColorAttributeName:selectColor} forState:UIControlStateSelected];
return segment;
}
- (void)segmentClick:(UISegmentedControl *)segment{
if (self.delegate && [self.delegate respondsToSelector:@selector(segmentValueChange:)]) {
[self.delegate segmentValueChange:segment];
}
}
@end
七(07)标签栏 【已经做成控件,暂无使用】tabBar
用法:
只需要在appDelegate中的didFinishLaunchingWithOptions方法中初始化后调用initCustomTabBar的方法即可
// HuTabBarViewController.h
#import <UIKit/UIKit.h>
@interface HuTabBarViewController : UITabBarController
@property (nonatomic, assign)NSInteger itemCount;//需要传入tabbar控制的视图控制器的个数
@property (nonatomic, strong)NSArray *unSelectImageArr;//默认tabbar上按钮的图片名称数组
@property (nonatomic, strong)NSArray *selectImageArr;//选择tabbar上按钮的图片名称数组
/**
在调用此方法之前必须将itemCount进行赋值
只需要在appDelegate中的didFinishLaunchingWithOptions方法中初始化后调用此方法即可
*/
-(void)initCustomTabBar;
@end
// HuTabBarViewController.m
#import "HuTabBarViewController.h"
@interface HuTabBarViewController ()
{
__weak UIButton *_selectBtn;
UIView *_lineView;
UIView *_tabBarBgView;
}
@end
@implementation HuTabBarViewController
- (instancetype)init{
if (self = [super init]) {
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)initCustomTabBar
{
_tabBarBgView =[[UIImageView alloc]initWithFrame:CGRectMake(0, HHBHEIGHT - tabBarView_height, HHBWIDTH, tabBarView_height)];
_tabBarBgView.backgroundColor=[UIColor whiteColor];
_tabBarBgView.userInteractionEnabled=YES;
[self.view addSubview:_tabBarBgView];
_lineView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, _tabBarBgView.frame.size.width, line_height)];
_lineView.backgroundColor = [HuConfigration uiColorFromString:border_line_color];
_lineView.alpha = 0.5;
[_tabBarBgView addSubview:_lineView];
//创建底部menu按钮:
for (int i = 0; i < self.itemCount; i++) {
if([_selectImageArr count] > i && [_unSelectImageArr count] > i){
[self createButton:i imageIndex:i+1];
}
}
}
- (UIButton *)createButton:(int)index imageIndex:(int)imageIndex {
int intervalX = HHBWIDTH / self.itemCount;
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(intervalX * index, 0, intervalX, tabBarView_height)];
button.tag = index + 1;
[button setImage:[UIImage imageNamed:_selectImageArr[index]] forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:_unSelectImageArr[index]] forState:UIControlStateSelected];
[button addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
[_tabBarBgView addSubview:button];
if (index == 0) {
button.selected = YES;
_selectBtn = button;
}
return button;
}
- (void)btnClick:(UIButton *)btn
{
//视图切换
self.selectedIndex = btn.tag-1;
//重复点击不起作用
if (btn == _selectBtn) return;
[btn setSelected:YES];
[_selectBtn setSelected:NO];
_selectBtn = btn;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
@end
八.搜索 [暂无做成控件]
08搜索:浅色底,取消按钮反白,浅色底,取消按钮为主色调
注意:部分宏不起作用,原因是系统自己适配了。
//08 搜索Search<app基础规范> 注意:部分宏不起作用,原因是系统自己适配了。
#define search_bar_xPos 15
#define search_bar_yPos 15
#define search_bar_width_has_rBtn (HHBWIDTH - 50 - search_bar_xPos) //右边含按钮的大小
#define search_bar_height 29
#define search_bar_round_corner 4
#define search_bar_corner_color [HuConfigration uiColorFromString:@"#CCCCCC"]
#define search_bar_icon_xPos 5
#define search_bar_icon_width 14
#define search_bar_icon_yPos (search_bar_height - search_bar_icon_width) / 2.0
#define search_bar_font fontsize_T3
#define search_bar_content_xPos (40 - search_bar_xPos) //通过放置一个空白视图(该值也是空白视图的宽度),使文字在指定位置输出
九 tab切换 [已经做成控件,暂无使用]
09 tab切换:主要用于同一个页面二级多个场景的切换,底部出现蓝色和蓝色文字为选中当前状态。当主色调为黑白色的时候,选中状态的颜色优先为蓝色系
用法:
将HuSliderTabBarView进行初始化并实现代理方法即可
//09 tab切换
#define tab_select_title_color fontcolor_C5
#define tab_title_font fontsize_T3
#define tab_title_color [HuConfigration uiColorFromString:@"#666666"]
#define tab_switch_view_height 40
#define tab_select_line_heigth 1.5f //选中时下划线的高度
#define tab_select_line_color fontcolor_C5 //选中时下划线的颜色
#define tab_line_height line_height
#define tab_normal_line_color border_line_color
// HuSliderTabBarView.h
#import <UIKit/UIKit.h>
@protocol HuSliderTabBarViewDelegate <NSObject>
/**
点击按钮执行的方法
*/
- (void)sliderButtonClick:(UIButton *)button;
@end
@interface HuSliderTabBarView : UIView
@property (nonatomic, assign)id< HuSliderTabBarViewDelegate >delegate;
/**
在需要的界面进行初始化
@param frame 传入上下整个视图的frame
@param titleArr 传入上面tab按钮的名称
*/
- (instancetype)initWithFrame:(CGRect)frame tiltleArray:(NSMutableArray *)titleArr;
@end
// HuSliderTabBarView.m
#import "HuSliderTabBarView.h"
#define TOPHEIGHT tab_switch_view_height
#define max_tab_cout 6 //1行最多显示5个
@interface HuSliderTabBarView()<UIScrollViewDelegate>
@property (assign) CGRect mViewFrame;///@brife 整个视图的大小
@property (strong, nonatomic) NSMutableArray *topViews; ///@brife 上方的数组
@property (strong, nonatomic) UIView *slideView;///@brife 下面滑动的View
@property (strong, nonatomic) UIView *topMainView;///@brife 上方的view
@property (strong, nonatomic) UIScrollView *topScrollView;///@brife 上方的ScrollView
@property (strong,nonatomic) NSMutableArray *buttonMutableArr;///@brife 上方按钮数组
@property (strong,nonatomic) UIButton *selectButton;///@brife 选中当前的按钮
@property (assign) NSInteger tabCount;
@end
@implementation HuSliderTabBarView
-(instancetype)initWithFrame:(CGRect)frame tiltleArray:(NSMutableArray *)titleArr{
self = [super initWithFrame:frame];
if (self ) {
_mViewFrame = frame;
_tabCount = titleArr.count;
_topViews = [[NSMutableArray alloc] init];
_buttonMutableArr = @[].mutableCopy;
[self initTopTabs:titleArr];
[self initSlideView];
}
return self;
}
#pragma mark -- 初始化滑动的指示View
-(void)initSlideView{
CGFloat width = _mViewFrame.size.width / max_tab_cout;
if(self.tabCount <= max_tab_cout){
width = _mViewFrame.size.width / self.tabCount;
}
_slideView = [[UIView alloc] initWithFrame:CGRectMake(0, TOPHEIGHT - tab_select_line_heigth, width, tab_select_line_heigth)];
[_slideView setBackgroundColor:[HuConfigration uiColorFromString:fontcolor_C5]];
[_topScrollView addSubview:_slideView];
}
#pragma mark -- 实例化顶部的tab
-(void) initTopTabs:(NSMutableArray *)titleArray{
CGFloat width = _mViewFrame.size.width / max_tab_cout;
if(self.tabCount <= max_tab_cout){
width = _mViewFrame.size.width / self.tabCount;
}
_topMainView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, _mViewFrame.size.width, TOPHEIGHT)];
[self addSubview:_topMainView];
_topScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, _mViewFrame.size.width, TOPHEIGHT)];
_topScrollView.showsHorizontalScrollIndicator = NO;
_topScrollView.showsVerticalScrollIndicator = YES;
_topScrollView.bounces = NO;
_topScrollView.delegate = self;
if (_tabCount >= max_tab_cout) {
_topScrollView.contentSize = CGSizeMake(width * _tabCount, TOPHEIGHT);
} else {
_topScrollView.contentSize = CGSizeMake(_mViewFrame.size.width, TOPHEIGHT);
}
[_topMainView addSubview:_topScrollView];
for (int i = 0; i < _tabCount; i ++) {
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(i * width, 0, width, TOPHEIGHT)];
self.selectButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, width, TOPHEIGHT)];
self.selectButton.tag = i;
[self.selectButton setTitle:[NSString stringWithFormat:@"%@",titleArray[i]] forState:UIControlStateNormal];
[self.selectButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
self.selectButton.titleLabel.font = tab_title_font;
[self.selectButton addTarget:self action:@selector(tabButton:) forControlEvents:UIControlEventTouchUpInside];
[view addSubview:self.selectButton];
[self.selectButton setTitleColor:[HuConfigration uiColorFromString:tab_title_color] forState:UIControlStateNormal];
[self.selectButton setTitleColor:[HuConfigration uiColorFromString:fontcolor_C5] forState:UIControlStateSelected];
[_buttonMutableArr addObject:self.selectButton];
[_topViews addObject:view];
[_topScrollView addSubview:view];
}
((UIButton *)[_buttonMutableArr objectAtIndex:0]).selected = YES;
//下划线
UILabel *line = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(self.topMainView.frame), _mViewFrame.size.width, line_height)];
line.backgroundColor = [HuConfigration uiColorFromString:border_line_color];;
[self addSubview:line];
}
#pragma mark --点击顶部的按钮所触发的方法
-(void) tabButton: (id) sender{
UIButton *button = sender;
((UIButton *)[_buttonMutableArr objectAtIndex:0]).selected = NO;
if (button != self.selectButton) {
self.selectButton.selected = NO;
self.selectButton = button;
}
self.selectButton.selected = YES;
CGRect frame = _slideView.frame;
CGFloat width = _mViewFrame.size.width / max_tab_cout;
frame.origin.x = self.selectButton.tag * width ;
_slideView.frame = frame;
if (self.delegate && [self.delegate respondsToSelector:@selector(sliderButtonClick:)]) {
[self.delegate sliderButtonClick:sender];
}
}
@end
十按钮
十一 按钮
十二 按钮
【已抽离成控件,可直接调用hu_button控件 引入头文件即可使用】
//10按钮
//HuButton 文件
#define btn_width_big 290 //一行只有一个按钮
#define btn_width 137.5 //一行两个按钮(这个比较正常)
#define btn_height 42
#define btn_round_conner 5.0
#define mainBtn_bgColor [HuConfigration uiColorFromString:@"#59AFF2"] //主按钮
#define mainBtn_press_bgColor [HuConfigration uiColorFromString:@"#2689d6"]
#define mainBtn_title_color fontcolor_C1
#define secBtn_bgColor fontcolor_C1 //次按钮
#define secBtn_border_line_color [HuConfigration uiColorFromString:@"#dddddd"]
#define secBtn_press_bgColor [HuConfigration uiColorFromString:@"#f8f8f8"]
#define secBtn_press_border_line_color [HuConfigration uiColorFromString:@"#d8d8d8"]
#define secBtn_title_color fontcolor_C3
#define unableBtn_title_color [HuConfigration uiColorFromString:@"#d2d2d2"]//不可点击按钮
#define unableBtn_bgColor [HuConfigration uiColorFromString:@"#EBEBF0"]
//11底部按钮(通栏)
//HuButton 文件
#define bottomBtn_height 43
#define bottomBtn_warnStatus_title_color [HuConfigration uiColorFromString:@"#FF513C"]
#define bottomBtn_nowarnStatus_title_color fontcolor_C2
#define bottomBtn_border_line_color secBtn_border_line_color
//12线框按钮
#define wireFrameBtn_round_conner 4.0
#define wireFrameBtn_border_color [HuConfigration uiColorFromString:@"#00AAEE"]
#define wireFrameBtn_2word_width 44
#define wireFrameBtn_3word_width 56
#define wireFrameBtn_4word_width 68
#define wireFrameBtn_height 25
#define wireFrameBtn_title_color [HuConfigration uiColorFromString:@"#00AAEE"]
// hu_Button.h
#import <UIKit/UIKit.h>
@interface HuButton : UIButton
// 规范第十条 isMainBtn值 1:主按钮 2:次按钮 3:不可点击 floatY:Y轴坐标 buttonTitle:按钮文字
+ (HuButton *)isMainBtn:(NSString *)isMainBtn floatY:(CGFloat)floatY buttonTitle:(NSString *)buttonTitle;
// 规范第十条 在一行内创建同时创建主次按钮 floatY:Y轴坐标 mainButtonTitle:主按钮文字 SecondButtonTitle:次按钮文字
+ (NSArray *)floatY:(CGFloat)floatY mainButtonTitle:(NSString *)mainButtonTitle secondButtonTitle:(NSString *)secondButtonTitle;
// 规范第十一条 btnType值 1:警示状态 2:非警示状态 3:不可点击状态 floatY:Y轴坐标 buttonTitle:按钮文字
+ (HuButton *)btnType:(HuBtnType )btnType floatY:(CGFloat)floatY buttonTitle:(NSString *)buttonTitle;
// 规范第十二条 floatX:X轴坐标 floatY:Y轴坐标 buttonTitle:按钮文字
+ (HuButton *)floatX:(CGFloat)floatX floatY:(CGFloat)floatY buttonTitle:(NSString *)buttonTitle;
@end
// hu_Button.m
#import "HuButton.h"
@implementation HuButton
+ (HuButton *)isMainBtn:(NSString *)isMainBtn floatY:(CGFloat)floatY buttonTitle:(NSString *)buttonTitle
{
//创建按钮对象
HuButton *button = [[HuButton alloc] init];
//设置按钮尺寸
button.frame = CGRectMake(([UIScreen mainScreen].bounds.size.width - btn_width_big)/2, floatY, btn_width_big , btn_height);
//设置按钮标题
[button setTitle:buttonTitle forState:UIControlStateNormal];
//设置圆角背景颜色及字体颜色
[button.layer setMasksToBounds:YES];
[button.layer setCornerRadius:btn_round_conner];
if ([isMainBtn isEqualToString:@"1"]) {
button.backgroundColor = mainBtn_bgColor;
[button setTitleColor:mainBtn_title_color forState:UIControlStateNormal];
//点击改变颜色
UIGraphicsBeginImageContextWithOptions(CGSizeMake(btn_width_big, btn_height),0, btn_height);
[mainBtn_press_bgColor set];
UIRectFill(CGRectMake(0,0,btn_width_big,btn_height));
UIImage *highLightImage =UIGraphicsGetImageFromCurrentImageContext();
[button setBackgroundImage:highLightImage forState:UIControlStateHighlighted];
}else if([isMainBtn isEqualToString:@"2"]){
[button.layer setBorderWidth:line_height];
button.layer.borderColor = secBtn_border_line_color.CGColor;
button.backgroundColor = secBtn_bgColor;
[button setTitleColor:secBtn_title_color forState:UIControlStateNormal];
//点击改变颜色
button.layer.borderColor = secBtn_press_border_line_color.CGColor;
UIGraphicsBeginImageContextWithOptions(CGSizeMake(btn_width_big, btn_height),0, btn_height);
[secBtn_press_bgColor set];
UIRectFill(CGRectMake(0,0,btn_width_big,btn_height));
UIImage *highLightImage =UIGraphicsGetImageFromCurrentImageContext();
[button setBackgroundImage:highLightImage forState:UIControlStateHighlighted];
}else { //默认是第三种不可点击状态
button.backgroundColor = unableBtn_bgColor;
[button setTitleColor:unableBtn_title_color forState:UIControlStateNormal];
[button setUserInteractionEnabled:NO];
}
//设置字体大小
button.titleLabel.font = fontsize_T1;
//设置按钮文字居中
button.titleLabel.textAlignment = NSTextAlignmentCenter;
return button;
}
+ (NSArray *)floatY:(CGFloat)floatY mainButtonTitle:(NSString *)mainButtonTitle secondButtonTitle:(NSString *)secondButtonTitle
{
//创建按钮对象
HuButton *button1 = [[HuButton alloc] init];
HuButton *button2 = [[HuButton alloc] init];
//设置按钮尺寸
button1.frame = CGRectMake(([UIScreen mainScreen].bounds.size.width-btn_width_big)/2, floatY, btn_width , btn_height);
button2.frame = CGRectMake(CGRectGetMaxX(button1.frame) + 7.5, floatY, btn_width , btn_height);
//设置按钮标题
[button1 setTitle:mainButtonTitle forState:UIControlStateNormal];
[button2 setTitle:secondButtonTitle forState:UIControlStateNormal];
//设置圆角背景颜色及字体颜色
[button1.layer setMasksToBounds:YES];
[button1.layer setCornerRadius:btn_round_conner];
[button2.layer setMasksToBounds:YES];
[button2.layer setCornerRadius:btn_round_conner];
button1.backgroundColor = mainBtn_bgColor;
[button1 setTitleColor:mainBtn_title_color forState:UIControlStateNormal];
//点击改变颜色
UIGraphicsBeginImageContextWithOptions(CGSizeMake(btn_width_big, btn_height),0, btn_height);
[mainBtn_press_bgColor set];
UIRectFill(CGRectMake(0,0,btn_width_big,btn_height));
UIImage *highLightImage1 =UIGraphicsGetImageFromCurrentImageContext();
[button1 setBackgroundImage:highLightImage1 forState:UIControlStateHighlighted];
[button2.layer setBorderWidth:line_height];
button2.layer.borderColor = secBtn_border_line_color.CGColor;
button2.backgroundColor = secBtn_bgColor;
[button2 setTitleColor:secBtn_title_color forState:UIControlStateNormal];
//点击改变颜色
button2.layer.borderColor = secBtn_press_border_line_color.CGColor;
UIGraphicsBeginImageContextWithOptions(CGSizeMake(btn_width_big, btn_height),0, btn_height);
[secBtn_press_bgColor set];
UIRectFill(CGRectMake(0,0,btn_width_big,btn_height));
UIImage *highLightImage2 =UIGraphicsGetImageFromCurrentImageContext();
[button2 setBackgroundImage:highLightImage2 forState:UIControlStateHighlighted];
//设置字体大小
button1.titleLabel.font = fontsize_T1;
button2.titleLabel.font = fontsize_T1;
//设置按钮文字居中
button1.titleLabel.textAlignment = NSTextAlignmentCenter;
button2.titleLabel.textAlignment = NSTextAlignmentCenter;
NSArray *btnList = [[NSArray alloc] initWithObjects:button1,button2,nil];
return btnList;
}
+ (HuButton *)btnType:(HuBtnType )btnType floatY:(CGFloat)floatY buttonTitle:(NSString *)buttonTitle
{
//创建按钮对象
HuButton *button = [[HuButton alloc] init];
//设置边框
[button.layer setMasksToBounds:YES];
[button.layer setBorderWidth:line_height];
button.layer.borderColor = bottomBtn_border_line_color.CGColor;
//设置按钮尺寸
button.frame = CGRectMake(-line_height, floatY, [UIScreen mainScreen].bounds.size.width+2*line_height , bottomBtn_height);
//设置按钮标题
[button setTitle:buttonTitle forState:UIControlStateNormal];
//设置字体大小
button.titleLabel.font = fontsize_T2;
//设置标题颜色
if (btnType == HuBtnTypeWaringMode) {
[button setTitleColor:bottomBtn_warnStatus_title_color forState:UIControlStateNormal];
}else if (btnType == HuBtnTypeNoWaringMode){
[button setTitleColor:bottomBtn_nowarnStatus_title_color forState:UIControlStateNormal];
}else {
[button setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
[button setUserInteractionEnabled:NO];
}
//设置按钮文字居中
button.titleLabel.textAlignment = NSTextAlignmentCenter;
//返回一个按钮
return button;
}
+ (HuButton *)floatX:(CGFloat)floatX floatY:(CGFloat)floatY buttonTitle:(NSString *)buttonTitle
{
//创建按钮对象
HuButton *button = [[HuButton alloc] init];
//设置边框
[button.layer setMasksToBounds:YES];
[button.layer setBorderWidth:2*line_height];
[button.layer setCornerRadius:wireFrameBtn_round_conner];
button.layer.borderColor = wireFrameBtn_border_color.CGColor;
//设置按钮尺寸
CGFloat width = 100;
if (buttonTitle.length == 4)
width = wireFrameBtn_4word_width;
else if(buttonTitle.length == 3)
width = wireFrameBtn_3word_width;
else if(buttonTitle.length == 2)
width = wireFrameBtn_2word_width;
button.frame = CGRectMake(floatX, floatY, width , wireFrameBtn_height);
//设置按钮标题
[button setTitle:buttonTitle forState:UIControlStateNormal];
//设置字体大小
button.titleLabel.font = fontsize_T4;
//设置字体颜色
[button setTitleColor:wireFrameBtn_title_color forState:UIControlStateNormal];
//设置按钮文字居中
button.titleLabel.textAlignment = NSTextAlignmentCenter;
//返回一个按钮
return button;
}
@end
使用示例:
//test
- (void)testFunction
{
NSArray *myBtnList = [HuButton floatY:400 mainButtonTitle:@"主按钮" secondButtonTitle:@"次按钮"];
HuButton *btn5 = [myBtnList objectAtIndex:0];
HuButton *btn6 = [myBtnList objectAtIndex:1];
[self.view addSubview:btn5];
[self.view addSubview:btn6];
//创建Button
HuButton *but = [HuButton btnType:HuBtnTypeWaringMode floatY:100 buttonTitle:@"我是按钮"];
//添加点击事件
[but addTarget:self action:@selector(action) forControlEvents:UIControlEventTouchUpInside];
//将控件添加到视图上
[self.view addSubview:but];
//十二按钮
HuButton *btn = [HuButton floatX:150 floatY:200 buttonTitle:@"我是按钮"];
[self.view addSubview:btn];
}
十三 行动操作 【暂时用系统自带的】
iOS自带控件能实现相关功能,暂没有宏定义以及自定义控件
十四 页边边距
//统一app里面所有内容与页边的间距
#define common_margin 15
十五 间距
//15 间距
#define navi_section_margin 15 //标题栏到section距离
#define section_section_margin 20 //section之间的距离
#define section_button_margin 30 //section到button之间的距离
#define button_button_margin 20 //button到button之间的距离
十六 间距
//16 间距
#define navi_head_margin 15 //标题文字到标题栏距离
#define sectionTitle_sectionCell_margin 10 //标题文字到section之间距离
#define hintTitle_button_margin 20 //说明文字到按钮之间距离
#define sectionCell_warnBtn_margin 20 //section到警示按钮之间的距离
十七 单行列表 Single list 【暂无定义成控件】
//单行列表主要由一行标题文字组成的列表,其样式有如下几种
相关宏定义如下:
//17.1 单行标题文字 左标题文字有内容 标题文字加开关
#define list_padding_lMargin 15 //左边距
#define list_padding_rMargin 15 //右边距
#define list_borderLine_height line_height
#define list_borderLine_color border_line_color
#define list_title_font fontsize_T2
#define list_title_color fontcolor_C2
#define list_redNumImage_yPos 4
#define list_redNumImage_width 14
#define list_redNumImage_height 14
#define list_redNumImage_font fontsize_T5
#define list_redNumImage_color fontcolor_C1
#define single_list_lTitle_xPos list_padding_lMargin
#define single_list_lTitle_rMargin 10
#define single_list_title_font list_title_font
#define single_lsit_title_color list_title_color
#define single_list_rContent_rMargin list_padding_rMargin
#define single_list_rContent_font fontsize_T3
#define single_list_rContent_color fontcolor_C4
#define single_list_sectionTitle_xPos list_padding_lMargin
#define single_list_sectionTitle_bMargin 10
#define single_list_sectionTitle_font fontsize_T4
#define single_list_sectionTitle_color fontcolor_C4
#define single_list_cellHeight 43
#define single_list_borderLine_height line_height
#define single_list_borderLine_color list_borderLine_color
//17.2 图片加标题文字,图片加标题文字加内容
#define single_list_lImage_xPos 15
#define single_list_lImage_width 29
#define single_list_lImage_height 29
十八 双行列表 Double line list 【暂无定义成控件】
//双行列表主要由上下两行文字组成的列表
相关宏定义如下:
//18.1上标题+下辅助文字
#define double_list_cellHeight 65
#define double_list_uTitle_yPos 13
#define double_list_uTitle_width 256
#define double_list_dContent_uMargin 3.5
//18.2 图片+标题+辅助文字 图片+标题+辅助文字+按钮
#define double_list_lImage_width 45
#define double_list_lImage_height 45
#define double_list_redNumImage_yPos list_redNumImage_yPos
#define double_list_redNumImage_width list_redNumImage_width
#define double_list_redNumImage_height list_redNumImage_height
#define double_list_redNumImage_font list_redNumImage_font
#define double_list_redNumImage_color list_redNumImage_color
#define double_list_content_width_has_rBtn 172.5
#define double_list_content_width_has_rArrowBtn 205
十九 三行列表Three line list 【暂无定义成控件】
//相比于双行列表,主要是内容多了一行
相关宏定义如下:
//相比于双行列表,主要是内容多了一行
#define three_list_cellHeight 85
#define three_list_content_width 268.5
#define three_list_lImage_width 45
#define three_list_lImage_height 71
#define three_list_lImage_rMargin 10
二十 列表展开 List expand
//用于场景出现点击展开的样式
相关宏定义如下:
#define list_expand_childContent_xPos 30
#define list_expand_childContent_font fontsize_T2
#define list_expand_childContent_color fontcolor_C3
二十一 列表选择 List select
//列表选择控件大致和单,双行控件一只,跟进业务场景多了勾选状态
相关宏定义如下:
#define list_select_rChoiceBtn_width 15
#define list_select_rChoiceBtn_height 15
#define list_select_rChoiceBtn_rMargin 15
二十二开关 系统自带的即可
//开关组件包含三种状态,Off/On,Dim
二十三删除 左滑删除 【暂时用系统】
//主要用来删除单个内容和多个内容
二十四 删除 选中删除
//用来删除单个内容和多个内容
#define selected_image_width 24
#define selected_image_height 24
#define selected_image_xPos 10
#define selected_image_rMargin 10 //右边距
二十五 基础提示框
//提示框是提醒用户在当前页面操作后得反馈提示,位于页面的中间
#define alertView_title_font ([HuConfigration systemFontOfPixelSize:28])
#define alertView_title_color fontcolor_C1 //白色
#define alertView_radius 4
二十六 更多
//他是一个native的容器,分别有iOS和安卓的容器决定,会根据不同的平台变化。
二十七.输入框
//主要有标题,输入内容,图标等元素组成。
#define input_height 43
#define input_label_lmargin 15
#define input_text_font fontsize_T3
#define input_text_color fontcolor_C2
#define input_hintLabel_font fontsize_T2
#define input_hintLabel_color fontcolor_C2
#define input_dark_hintLabel_font fontsize_T3 //暗提示
#define input_dark_hintLabel_color [HuConfigration uiColorFromString:@"#cccccc"]
#define input_dark_hintLabel_xPos 94 //主标签小于等于4个字
#define input_dark_hintLabel_large_xPos 110 //主标签有5个字
二十八,文本
//由于某些使用场景,导致文本不可控,因此推出几个文本样式以供选择。
//28文本 一般用于tableview列表的自定义cell单元
//由于某些使用场景,导致文本不可控,因此推出几个文本样式以供选择。
//28.1 第一种cell 标题+内容+更多 [多内容cell]
#define multiContentCell_width 203
#define mulitContentCell_title_font fontsize_T4
#define multiContentCell_title_color fontcolor_C3
#define multiContentCell_title_xPos 15
#define multiContentCell_title_uMargin 15 //上边距
#define multiContentCell_title_dMargin 10 //下边距
#define mulitContentCell_subtitle_font fontsize_T2
#define multiContentCell_subtitle_color [HuConfigration uiColorFromString:@"#000000"]
#define multiContentCell_subtitle_uMargin 15
#define multiContentCell_content_font fontsize_T3
#define multiContentCell_content_color fontcolor_C3
#define multiContentCell_content_uMargin 6.5
#define multiContentCell_content_row_margin 8 //内容行间距
#define multiContentCell_datetime_font fontsize_T4
#define multiContentCell_datetime_color fontcolor_C4
#define multiContentCell_datetime_uMargin 15
#define multiContenCell_moreLinkBtn_font fontsize_T3
#define multiContenCell_moreLinkBtn_color fontcolor_C5
#define multiContenCell_moreLinkBtn_uMargin 15
#define multiContenCell_moreLinkBtn_dMargin 15
//28.2 第二种cell (标题+日期+图片+内容+文字链) [富文本图片cell]
#define richTextImageCell_title_font fontsize_T1
#define richTextImageCell_title_color [HuConfigration uiColorFromString:@"#000000"]
#define richTextImageCell_title_xPos 15
#define richTextImageCell_title_uMargin 20
#define richTextImageCell_datetime_font fontsize_T4
#define richTextImageCell_datetime_color fontcolor_C4
#define richTextImageCell_datetime_uMargin 3.5
#define richTextImageCell_image_width 290
#define richTextImageCell_image_uMargin 20
#define richTextImageCell_content_uMargin 20
#define richTextIamgeCell_wordLink_font fontsize_T3
#define richTextImageCell_wordLink_color fontcolor_C5
#define richTextImageCell_wordLink_uMargin 15
二十九 29情感化空白页面设计 Emotional blank page 【暂无使用】
//插画能够更生动的展示页面应用场景和说明内页。建议插画内容在270*270以内,重要功能空白页面,有主按钮页面设计
相关宏定义:
#define blank_page_image_width 135
#define blank_page_image_height 135
#define blank_page_image_hasBtn_yPos 75
#define blank_page_image_hasBtn_dMargin 25
#define blank_page_btn_uMargin 40
#define blank_page_text_font fontsize_T2
#define blank_page_text_color fontcolor_C4
#define blank_page_text_row_margin 8
三十 情感化空白页设计
//插画能够更生动的展示页面应用场景和说明内页。次级空白页面使用次级按钮,无需按钮有如右图设计方式
相关宏定义:
#define blank_page_image_yPos 120
三十一 插画弹层(单按钮) Illustration layer 【暂时还没做成控件】
//插画弹层样式有两种,单按钮加插画或双按钮加插画,能够让页面更生动有趣。
相关宏定义如下:
#define illustration_layer_width 270
#define illustration_layer_height 315
#define illustration_layer_topRight_cancelBtn_width 24
#define illustration_layer_topRight_cancelBtn_height 24
#define illustration_layer_topRight_cancelBtn_dMargin 15
#define illustration_layer_image_yPos 30
#define illustration_layer_image_width 240
#define illustration_layer_image_height 160
#define illustration_layer_text_uMargin 15
#define illustration_layer_text_dMargin 15
#define illustration_layer_text_row_margin 8
#define illustration_layer_text_font fontsize_T3
#define illustration_layer_text_color [HuConfigration uiColorFromString:@"#aaaaaa"]
#define illustration_layer_mainBtn_width 240
#define illustration_layer_mainBtn_height 43
#define mask_layer_color [HuConfigration uiColorFromString:@"#000000"] //黑色
#define mask_layer_opacity 0.5 //半透明
三十二 插画弹层(双按钮) Illustration layer two button 【暂时还没做成控件】
//插画弹层样式有两种,单按钮加插画或双按钮加插画,能够让页面更生动有趣。
相关宏宏定义:
#define illustration_layer_twoBtn_height 290
#define illustration_layer_twoBtn_text_dMargin 20
#define illustration_layer_dividing_line_color [HuConfigration uiColorFromString:@"#afafbc"]
#define illustration_layer_verticalLine_height 50 //竖线
#define illustration_layer_mainBtn_font mainBtn_font
#define illustration_layer_mainBtn_color fontcolor_C5
#define illustration_layer_secondaryBtn_color fontcolor_C3
三十三 文字弹层 Text layer 【暂时没用,先用系统默认的弹出框】
//文字弹层样色有两种,单按钮加文案和双按钮加文案。
相关宏定义
#define text_layer_title_yPos 20
#define text_layer_title_dMargin 10
#define text_layer_title_font fontsize_T2
#define text_layer_title_color fontcolor_C2
#define text_layer_content_xPos 20
#define text_layer_content_rMargin 20
#define text_layer_content_dMargin 20
#define text_layer_content_color [HuConfigration uiColorFromString:@"#aaaaaa"]
其他自定义消息
//IM自定义消息
#define msg_title_height 18
#define msg_title_width 160
#define msg_title_font fontsize_T2
#define msg_title_color fontcolor_C1
#define msg_subTitle_height 16
#define msg_subTitle_font fontsize_T4
#define msg_subTitle_color fontcolor_C1
#define msg_imageView_height 35
#define msg_imageView_width 35
#define msg_followUp_image @"msg_flowup"
#define msg_satisfaction_image @"msg_satisfaction"
如果您发现本文对你有所帮助,如果您认为其他人也可能受益,请把它分享出去。