将该头文件 加入到 PCH 中即可;
//
// InlineMethod.h
// FileTransfer
//
// Created by HMC on 16/9/5.
// Copyright © 2016年 SKing. All rights reserved.
//
#ifndef InlineMethod_h
#define InlineMethod_h
#import <UIKit/UIKit.h>
/**
* 设置宽度
*
* @param view 设置的对象 view
* @param width 宽度
*
* @return nil
*/
static inline void setWidth(UIView * view, CGFloat width){
CGRect frame = view.frame;
frame.size.width = width;
view.frame = frame;
}
/**
* 获取宽度
*
* @param view 设置的对象 view
*
* @return 宽度
*/
static inline CGFloat getWidth(UIView * view){
return view.frame.size.width;
}
/**
* 设置高度
*
* @param view 设置的对象 view
* @param width 高度
*
* @return nil
*/
static inline void setHeight(UIView * view, CGFloat height){
CGRect frame = view.frame;
frame.size.height = height;
view.frame = frame;
}
/**
* 获取高度
*
* @param view 设置的对象 view
*
* @return 高度
*/
static inline CGFloat getHeight(UIView * view){
return view.frame.size.height;
}
/**
* 缩小放大的帧动画
*
* @return 返回帧动画
*/
static inline CAKeyframeAnimation * caKeyframeAnimation (){
CAKeyframeAnimation * keyAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
keyAnimation.duration = 0.4;
keyAnimation.removedOnCompletion = YES;
keyAnimation.fillMode = kCAFillModeForwards;
//layer 动画的轨迹点
keyAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.5, 0.5, 1.0)],
[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.3, 1.3, 1.0)],
[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];
return keyAnimation;
}
/**
* 获取宽高
*
* @return 宽高
*/
#define SCREENWIDTH [UIScreen mainScreen].bounds.size.width
#define SCREENHEIGHT [UIScreen mainScreen].bounds.size.height
/**
* 设置颜色
*
* @param r 红
* @param g 绿
* @param b 蓝
* @param a 透明度
*
* @return UIColor
*/
#define setRGBColor(r,g,b,a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
/**
* 定义弱引用 self
*
* @param self 本身
*
* @return 弱 self
*/
#define weaklySelf(self) __weak typeof(self) weakSelf = self
#define stronglySelf(self) __strong typeof(self) strongSelf = self
/**
* 获取 class 所在的 bundle
*
* @return 返回 bundle
*/
#define getBundle [NSBundle bundleForClass:[self class]]
// 图片路径
#define getPicName(picName) [@"图片封装的bundle名字(*****.bundle)" stringByAppendingPathComponent: picName]
#define getAllFrameworkOfPicName(picName) [@"全路径" stringByAppendingPathComponent: picName]
#endif /* InlineMethod_h */