项目方法集合HTools(2)

github地址链接:https://github.com/KingXcode/HTTools

这是我在项目中慢慢积累的方法集合,有些是自己写的,有些是觉得网上的写的挺好的就给自己搬过来了。

  • UITableViewCell+HTDelaysContentTouches.h
正常情况下cell中放置button等控件点击效果会产生延时的效果
有的时候不需要可使用这个属性进行取消
@property (nonatomic, assign) BOOL ht_delaysContentTouches;
  • UIResponder+HTFirstResponder.h
获取到当前界面的第一响应者
+ (id)ht_currentFirstResponder;
  • UIControl+HTSound.h
给不同的点击事件添加不同的声音
name:是存放在bundle中的音频文件的名字
- (void)ht_setSoundNamed:(NSString *)name forControlEvent:(UIControlEvents)controlEvent;
点击事件回调
放在UIControl的分类中,只要是UIControl的子类都能使用
分类名叫HTSound,呵呵没有新建分类,不要见怪
- (void)ht_touchDown:(void (^)(void))eventBlock;
- (void)ht_touchDownRepeat:(void (^)(void))eventBlock;
- (void)ht_touchDragInside:(void (^)(void))eventBlock;
- (void)ht_touchDragOutside:(void (^)(void))eventBlock;
- (void)ht_touchDragEnter:(void (^)(void))eventBlock;
- (void)ht_touchDragExit:(void (^)(void))eventBlock;
- (void)ht_touchUpInside:(void (^)(void))eventBlock;
- (void)ht_touchUpOutside:(void (^)(void))eventBlock;
- (void)ht_touchCancel:(void (^)(void))eventBlock;
- (void)ht_valueChanged:(void (^)(void))eventBlock;
- (void)ht_editingDidBegin:(void (^)(void))eventBlock;
- (void)ht_editingChanged:(void (^)(void))eventBlock;
- (void)ht_editingDidEnd:(void (^)(void))eventBlock;
- (void)ht_editingDidEndOnExit:(void (^)(void))eventBlock;
  • UIButton+HT.h
利用UIButton的titleEdgeInsets和imageEdgeInsets来实现文字和图片的自由排列
注意:这个方法需要在设置图片和文字之后才可以调用,且button的大小要大于 图片大小+文字大小+spacing
- (void)ht_setImagePosition:(HTImagePosition)postion spacing:(CGFloat)spacing;
  • UIView+HTRedPoint
设置红点数
-(void)ht_setRedNumber:(NSString *)num;

设置红点数的区间
半开半闭区间  example: (0,99]
-(void)ht_redPointAutomaticHiddenByMinLimit:(NSInteger)minNumber MaxLimit:(NSInteger)maxNumber;

更新尺寸---就是重置红点的大小,根据自身的实际情况设置
-(void)ht_updateRedPointSize:(CGSize)size;

相对于原始位置的偏移量
Ps.原始位置的中心点就是view本身的右上角
-(void)ht_updateRedPointOriginOffset:(CGPoint)offset;

设置红点是否只是显示一个点
前提是有设置ht_setRedNumber这个方法 
isShow 当为ture 时 会根据设置的num 和区间来显示
-(void)ht_showMinRedPoint:(BOOL)isShow;
  • HTTools+Annimation
创建动画   可以将动画放在navi的layer上做动画跳转
+ (CATransition *)createTransitionAnimationWithType:(NSString *)type direction:(NSString *)direction time:(double)time;

从右边滑出来
+(void)TransformView:(UIView *)view;

 从小变大
+(void)CATransform3DScaleView:(UIView *)view;

竖直缩放
+(void)CATransform3DScaleVerticalView:(UIView *)view;
+(void)CATransform3DScaleVerticalView:(UIView *)view Duration:(NSTimeInterval)duration;

 抖动
+(void)shakeAnnimation:(UIView *)view completion:(void (^)(BOOL finished))completion;

工具中海有些其他的tools,也是项目里比较常用的,就不全部做解释了。
当然很多地方的代码也可能写的不是很高明,欢迎大神对我指点一二。
😁😁😁😁

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • *7月8日上午 N:Block :跟一个函数块差不多,会对里面所有的内容的引用计数+1,想要解决就用__block...
    炙冰阅读 7,311评论 1 14
  • 废话不多说,直接上干货 ---------------------------------------------...
    小小赵纸农阅读 8,778评论 0 15
  • 伴随本身的糖果甜香。 洗完澡。 头发湿润。 悠懒在沙发上。 看着时间一分分的消逝。 连续失眠, 多么希望手边有杯牛...
    _茉茉阅读 1,144评论 0 0
  • 抽烟 哥抽的不是香烟,而是寂寞。
    罂粟之恋阅读 803评论 0 0
  • jsjdhdj
    不可爱m阅读 493评论 0 0