Initial commit
This commit is contained in:
Vendored
BIN
Binary file not shown.
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// CustomeLabel.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 17/2/24.
|
||||
// Copyright © 2017年 lianlian. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface CustomeLabel : UILabel
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,105 @@
|
||||
//
|
||||
// CustomeLabel.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 17/2/24.
|
||||
// Copyright © 2017年 lianlian. All rights reserved.
|
||||
//
|
||||
|
||||
#import "CustomeLabel.h"
|
||||
|
||||
@implementation CustomeLabel
|
||||
|
||||
/*
|
||||
// Only override drawRect: if you perform custom drawing.
|
||||
// An empty implementation adversely affects performance during animation.
|
||||
- (void)drawRect:(CGRect)rect {
|
||||
// Drawing code
|
||||
}
|
||||
*/
|
||||
|
||||
- (void)awakeFromNib{
|
||||
[super awakeFromNib];
|
||||
|
||||
[self addLongPressEvent];
|
||||
}
|
||||
- (instancetype)initWithFrame:(CGRect)frame{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
|
||||
[self addLongPressEvent];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)addLongPressEvent{
|
||||
|
||||
self.userInteractionEnabled = YES;
|
||||
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(actionS:)];
|
||||
[self addGestureRecognizer:longPress];
|
||||
|
||||
}
|
||||
|
||||
|
||||
- (void)actionS:(UILongPressGestureRecognizer *)gesture{
|
||||
|
||||
if (gesture.state == UIGestureRecognizerStateBegan) {
|
||||
|
||||
[self becomeFirstResponder];
|
||||
UIMenuItem *menuItem1 = [[UIMenuItem alloc] initWithTitle:@"拷贝" action:@selector(copyS:)];
|
||||
//UIMenuItem *menuItem2 = [[UIMenuItem alloc] initWithTitle:@"粘贴" action:@selector(pasteS:)];
|
||||
//UIMenuItem *menuItem3 = [[UIMenuItem alloc] initWithTitle:@"剪切哦" action:@selector(cutS:)];
|
||||
UIMenuController *menuC = [UIMenuController sharedMenuController];
|
||||
|
||||
menuC.menuItems = @[menuItem1];
|
||||
menuC.arrowDirection = UIMenuControllerArrowUp;
|
||||
|
||||
if (menuC.menuVisible) {
|
||||
// NSLog(@"menuC.menuVisible 判断 -- %d", menuC.menuVisible);
|
||||
return ;
|
||||
}
|
||||
|
||||
[menuC setTargetRect:self.frame inView:self.superview];
|
||||
[menuC setMenuVisible:YES animated:YES];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)canBecomeFirstResponder{
|
||||
return YES;
|
||||
|
||||
}
|
||||
|
||||
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender{
|
||||
|
||||
if ( action == @selector(copyS:) || (action == @selector(pasteS:) && [UIPasteboard generalPasteboard].string) || action == @selector(cutS:) ) {
|
||||
// NSLog(@"粘贴板 -- %@", [UIPasteboard generalPasteboard].string);
|
||||
return YES;
|
||||
}else{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
//剪切事件(暂时不用)
|
||||
- (void)cutS:(id)sender{
|
||||
|
||||
UIPasteboard *pboard = [UIPasteboard generalPasteboard];
|
||||
pboard.string = self.text;
|
||||
//剪切 功能
|
||||
self.text = nil;
|
||||
}
|
||||
|
||||
//拷贝
|
||||
- (void)copyS:(id)sender{
|
||||
|
||||
UIPasteboard *pboard = [UIPasteboard generalPasteboard];
|
||||
pboard.string = self.text;
|
||||
|
||||
}
|
||||
//粘贴
|
||||
- (void)pasteS:(id)sender{
|
||||
|
||||
UIPasteboard *pboard = [UIPasteboard generalPasteboard];
|
||||
self.text = pboard.string;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// IfishDeviceInfo.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 17/1/5.
|
||||
// Copyright © 2017年 lianxiang. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef IfishDeviceInfo_h
|
||||
#define IfishDeviceInfo_h
|
||||
|
||||
//零控
|
||||
#define DECICE_TYPE_ZEROEBIG @"0a" //0x0a//大屏
|
||||
#define DECICE_TYPE_ZEROESAMLL @"1a" //0x1a//小屏
|
||||
|
||||
//两控
|
||||
#define DECICE_TYPE_TWONORMALL @"0b" //0x0b//普通
|
||||
#define DECICE_TYPE_TWOMINJIANG @"0d" //0x0d//闽江
|
||||
|
||||
//三控
|
||||
#define DECICE_TYPE_THREENORMALL @"0c" //0x0c
|
||||
#define DECICE_TYPE_THREETMP @"1c" //0x1c
|
||||
|
||||
//四控
|
||||
#define DECICE_TYPE_FOURNORMALL @"0e" //0x0e
|
||||
|
||||
//陈工方案
|
||||
#define DECICE_TYPE_CHEN @"01" //0x01
|
||||
|
||||
//绚多
|
||||
#define DECICE_TYPE_XUANDUOOF @"0f" //0x0f//无屏幕
|
||||
#define DECICE_TYPE_XUANDUO1F @"1f" //0x1f//有屏幕
|
||||
|
||||
//可丽爱
|
||||
#define DECICE_TYPE_KELIAI @"aa" //0xaa
|
||||
|
||||
//松诺
|
||||
#define DECICE_TYPE_SONGBB @"bb" //0xbb//无屏幕
|
||||
#define DECICE_TYPE_SONGBC @"bc" //0xbc//有屏幕
|
||||
|
||||
//松诺新
|
||||
#define DECICE_TYPE_SONGNEWBD @"bd" //0xbd
|
||||
|
||||
//四川聚能
|
||||
#define DECICE_TYPE_JUNENGCC @"cc" //0xcc
|
||||
//睿芯 独立 84 字节
|
||||
#define DECICE_TYPE_RUSUN2A @"2a" //0x2a
|
||||
|
||||
|
||||
#endif /* IfishDeviceInfo_h */
|
||||
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// IfishUserDefaultHelper.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/11/29.
|
||||
// Copyright © 2016年 lianxiang. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface IfishUserDefaultHelper : NSObject
|
||||
|
||||
+(void)showAdview:(BOOL)show;
|
||||
|
||||
+(BOOL)digShowAdview;
|
||||
|
||||
+(void)clearUserWhenUserChange;
|
||||
|
||||
+(void)saveExpTimeWithFormateTime:(NSString *)time;
|
||||
|
||||
+(NSString *)getExpTimeFormDefault;
|
||||
|
||||
+(NSString *)getDefualtGradNum;
|
||||
+(void)chageLevlelGrad:(NSString *)gradNum;
|
||||
|
||||
//任务引导
|
||||
+(void)IfishTaskIsShowed:(BOOL)show;
|
||||
+(BOOL)digisShowTaskLead;
|
||||
|
||||
//资讯id
|
||||
+(void)saveinfoId:(NSString *)infoid;
|
||||
|
||||
+(NSString *)getDefualtInfoId;
|
||||
|
||||
//保存实时动态未读数已知最大值
|
||||
+(void)saveUserActivityMaxId:(NSString *)maxId;
|
||||
//获取本地实时动态最大Id
|
||||
+(NSString *)localCurrentUserActivityMaxId;
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,153 @@
|
||||
//
|
||||
// IfishUserDefaultHelper.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/11/29.
|
||||
// Copyright © 2016年 lianxiang. All rights reserved.
|
||||
//
|
||||
|
||||
#import "IfishUserDefaultHelper.h"
|
||||
#define USERDEFAULT_ADVIEWKEY @"IfishshowAdview"
|
||||
#define IFISHTASK_LEAD @"ifishTaskLeadShow"
|
||||
@implementation IfishUserDefaultHelper
|
||||
|
||||
+(void)showAdview:(BOOL)show
|
||||
{
|
||||
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||||
[userdefult setBool:show forKey:USERDEFAULT_ADVIEWKEY];
|
||||
[userdefult synchronize];
|
||||
|
||||
}
|
||||
|
||||
+(BOOL)digShowAdview
|
||||
{
|
||||
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||||
BOOL showAdview =[userdefult boolForKey:USERDEFAULT_ADVIEWKEY];
|
||||
[userdefult synchronize];
|
||||
return showAdview;
|
||||
|
||||
}
|
||||
|
||||
+(void)IfishTaskIsShowed:(BOOL)show
|
||||
{
|
||||
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||||
[userdefult setBool:show forKey:IFISHTASK_LEAD];
|
||||
[userdefult synchronize];
|
||||
}
|
||||
|
||||
+(BOOL)digisShowTaskLead
|
||||
{
|
||||
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||||
BOOL show =[userdefult boolForKey:IFISHTASK_LEAD];
|
||||
[userdefult synchronize];
|
||||
return show;
|
||||
}
|
||||
|
||||
+(void)clearUserWhenUserChange{
|
||||
|
||||
//切换 时重置标志位 等级信息清除
|
||||
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||||
NSInteger index=0;
|
||||
[userdefult setInteger:index forKey:@"lastIndex"];
|
||||
[userdefult setObject:@"1" forKey:@"isExit"];
|
||||
[userdefult setObject:nil forKey:@"password"];
|
||||
[userdefult setObject:nil forKey:@"cameralastIndex"];
|
||||
[userdefult setObject:nil forKey:@"gradeNum"];
|
||||
//金币标志位
|
||||
[userdefult setObject:nil forKey:EVERYDAYSIGNIN];
|
||||
[userdefult setObject:nil forKey:READINFORMATION];
|
||||
[userdefult setObject:nil forKey:OPENGOODSLINK];
|
||||
[userdefult setObject:nil forKey:ROOMLEAVEMSG];
|
||||
[userdefult setObject:nil forKey:IFISHCOMMUNITY];
|
||||
[userdefult setObject:nil forKey:SHARECAMERAPICTURE];
|
||||
[userdefult setObject:nil forKey:SHARELOOKREPORT];
|
||||
[userdefult setObject:nil forKey:RENAME];
|
||||
[userdefult setObject:nil forKey:OPLOADHEADIMG];
|
||||
[userdefult setObject:nil forKey:OPENSHARECAMERA];
|
||||
[userdefult setObject:nil forKey:CHIOCELOOKSHOPS];
|
||||
[userdefult setObject:nil forKey:IFISHDOCTOR];
|
||||
[userdefult setObject:nil forKey:SHAREIFISHAPP];
|
||||
//经验标志位
|
||||
[userdefult setObject:nil forKey:IFISHADDEXP_BIDDEVICE];
|
||||
[userdefult setObject:nil forKey:IFISHADDEXP_BIDCAMERA];
|
||||
[userdefult setObject:nil forKey:IFISHADDEXP_LOGIN];
|
||||
//任务
|
||||
[userdefult setBool:NO forKey:IFISHTASK_LEAD];
|
||||
[userdefult synchronize];
|
||||
|
||||
}
|
||||
|
||||
+(void)saveExpTimeWithFormateTime:(NSString *)time
|
||||
{
|
||||
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||||
[userdefult setObject:time forKey:@"IfishGetExpTime"];
|
||||
[userdefult synchronize];
|
||||
|
||||
}
|
||||
|
||||
+(NSString *)getExpTimeFormDefault
|
||||
{
|
||||
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||||
NSString *time =[userdefult objectForKey:@"IfishGetExpTime"];
|
||||
[userdefult synchronize];
|
||||
return time;
|
||||
}
|
||||
|
||||
+(NSString *)getDefualtGradNum
|
||||
{
|
||||
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||||
NSString *time =[userdefult objectForKey:@"gradeNum"];
|
||||
[userdefult synchronize];
|
||||
return time;
|
||||
|
||||
}
|
||||
+(void)chageLevlelGrad:(NSString *)gradNum
|
||||
{
|
||||
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||||
[userdefult setObject:gradNum forKey:@"gradeNum"];
|
||||
[userdefult synchronize];
|
||||
}
|
||||
|
||||
+(void)saveinfoId:(NSString *)infoid{
|
||||
|
||||
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||||
[userdefult setObject:infoid forKey:@"curentInfoId"];
|
||||
[userdefult synchronize];
|
||||
}
|
||||
|
||||
+(NSString *)getDefualtInfoId{
|
||||
|
||||
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||||
NSString *infoId =[userdefult objectForKey:@"curentInfoId"];
|
||||
//infoId nsnumber xing
|
||||
NSString *idinfo = [NSString stringWithFormat:@"%@",infoId];
|
||||
if (!idinfo) {
|
||||
idinfo = @"";
|
||||
}
|
||||
[userdefult synchronize];
|
||||
return idinfo;
|
||||
}
|
||||
|
||||
+(void)saveUserActivityMaxId:(NSString *)maxId
|
||||
{
|
||||
if (!maxId||[maxId isKindOfClass:[NSNull class]]) {
|
||||
maxId = @"0";
|
||||
}
|
||||
|
||||
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||||
[userdefult setObject:maxId forKey:@"UserActivityMaxId"];
|
||||
[userdefult synchronize];
|
||||
|
||||
}
|
||||
|
||||
+(NSString *)localCurrentUserActivityMaxId
|
||||
{
|
||||
NSString *curentMaxid;
|
||||
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||||
curentMaxid =[userdefult objectForKey:@"UserActivityMaxId"];
|
||||
if (!curentMaxid) {
|
||||
curentMaxid = @"0";
|
||||
}
|
||||
return curentMaxid;
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// LXADViewTool.h
|
||||
// ShotViewAnimation
|
||||
//
|
||||
// Created by imac on 16/10/17.
|
||||
// Copyright © 2016年 xiang. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface LXADViewTool : NSObject
|
||||
|
||||
/**
|
||||
* 关闭按钮的位置
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, ButtonPositionType) {
|
||||
/**
|
||||
* 无
|
||||
*/
|
||||
ButtonPositionTypeNone = 0,
|
||||
/**
|
||||
* 左上角
|
||||
*/
|
||||
ButtonPositionTypeLeft = 1 << 0,
|
||||
/**
|
||||
* 右上角
|
||||
*/
|
||||
ButtonPositionTypeRight = 2 << 0
|
||||
};
|
||||
|
||||
/**
|
||||
* 蒙板的背景色
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, ShadeBackgroundType) {
|
||||
/**
|
||||
* 渐变色
|
||||
*/
|
||||
ShadeBackgroundTypeGradient = 0,
|
||||
/**
|
||||
* 固定色
|
||||
*/
|
||||
ShadeBackgroundTypeSolid = 1 << 0
|
||||
};
|
||||
|
||||
typedef void(^completeBlock)(void);
|
||||
|
||||
@property (strong, nonatomic) UIColor *popBackgroudColor;//弹出视图的背景色
|
||||
@property (assign, nonatomic) BOOL tapOutsideToDismiss;//点击蒙板是否弹出视图消失
|
||||
@property (assign, nonatomic) ButtonPositionType closeButtonType;//关闭按钮的类型
|
||||
@property (assign, nonatomic) ShadeBackgroundType shadeBackgroundType;//蒙板的背景色
|
||||
|
||||
/**
|
||||
* 创建一个实例
|
||||
*
|
||||
* @return CHWPopTool
|
||||
*/
|
||||
+ (LXADViewTool *)sharedInstance;
|
||||
/**
|
||||
* 弹出要展示的View
|
||||
*
|
||||
* @param presentView show View
|
||||
* @param animated 是否动画
|
||||
*/
|
||||
- (void)showWithPresentView:(UIView *)presentView animated:(BOOL)animated;
|
||||
/**
|
||||
* 关闭弹出视图
|
||||
*
|
||||
* @param complete complete block
|
||||
*/
|
||||
- (void)closeWithBlcok:(void(^)())complete;
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,325 @@
|
||||
//
|
||||
// LXADViewTool.m
|
||||
// ShotViewAnimation
|
||||
//
|
||||
// Created by imac on 16/10/17.
|
||||
// Copyright © 2016年 xiang. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LXADViewTool.h"
|
||||
static NSTimeInterval const kFadeInAnimationDuration = 0.7;
|
||||
static NSTimeInterval const kTransformPart1AnimationDuration = 0.3;
|
||||
static NSTimeInterval const kTransformPart2AnimationDuration = 0.4;
|
||||
static CGFloat const kDefaultCloseButtonPadding = 17.0f;
|
||||
|
||||
|
||||
/**
|
||||
* 自定义的view
|
||||
*/
|
||||
@interface MyView : UIView
|
||||
@property (weak, nonatomic) CALayer *styleLayer;
|
||||
@property (strong, nonatomic) UIColor *popBackgroundColor;
|
||||
@end
|
||||
|
||||
//遮罩
|
||||
@interface shadeView : UIView
|
||||
|
||||
@end
|
||||
/**
|
||||
* 自定义的VC
|
||||
*/
|
||||
@interface MyViewController : UIViewController
|
||||
@property (weak, nonatomic) shadeView *styleView;
|
||||
@end
|
||||
|
||||
/**
|
||||
* 自定义的button
|
||||
*/
|
||||
@interface MyButton : UIButton
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* HWPopTool
|
||||
*/
|
||||
@interface LXADViewTool ()
|
||||
@property (strong, nonatomic) UIWindow *window;
|
||||
@property (strong, nonatomic) UIViewController *contentViewController;
|
||||
@property (weak, nonatomic) MyViewController *viewController;
|
||||
@property (weak, nonatomic) MyView *containerView;
|
||||
@property (weak, nonatomic) MyButton *closeButton;
|
||||
|
||||
@end
|
||||
|
||||
@implementation LXADViewTool
|
||||
|
||||
+ (LXADViewTool *)sharedInstance {
|
||||
static LXADViewTool *sharedClient = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sharedClient = [[LXADViewTool alloc]init];
|
||||
});
|
||||
return sharedClient;
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.closeButtonType = ButtonPositionTypeLeft;
|
||||
self.tapOutsideToDismiss = YES;
|
||||
self.popBackgroudColor = [UIColor colorWithWhite:0 alpha:0.5];
|
||||
};
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setCloseButtonType:(ButtonPositionType)closeButtonType {
|
||||
|
||||
_closeButtonType = closeButtonType;
|
||||
if (closeButtonType == ButtonPositionTypeNone) {
|
||||
[self.closeButton setHidden:YES];
|
||||
} else {
|
||||
[self.closeButton setHidden:NO];
|
||||
|
||||
CGRect closeFrame = self.closeButton.frame;
|
||||
if(closeButtonType == ButtonPositionTypeRight){
|
||||
closeFrame.origin.x = round(CGRectGetWidth(self.containerView.frame) - kDefaultCloseButtonPadding - CGRectGetWidth(closeFrame)/2);
|
||||
} else {
|
||||
closeFrame.origin.x = 0;
|
||||
}
|
||||
self.closeButton.frame = closeFrame;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showWithPresentView:(UIView *)presentView animated:(BOOL)animated {
|
||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
self.window.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
|
||||
self.window.opaque = NO;
|
||||
|
||||
MyViewController *viewController = [[MyViewController alloc] init];
|
||||
self.window.rootViewController = viewController;
|
||||
self.viewController = viewController;
|
||||
|
||||
CGFloat padding = 17;
|
||||
CGRect containerViewRect = CGRectInset(presentView.bounds, -padding, -padding);
|
||||
containerViewRect.origin.x = containerViewRect.origin.y = 0;
|
||||
containerViewRect.origin.x = round(CGRectGetMidX(self.window.bounds) - CGRectGetMidX(containerViewRect));
|
||||
containerViewRect.origin.y = round(CGRectGetMidY(self.window.bounds) - CGRectGetMidY(containerViewRect));
|
||||
MyView *containerView = [[MyView alloc] initWithFrame:containerViewRect];
|
||||
containerView.popBackgroundColor = self.popBackgroudColor;
|
||||
containerView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|
|
||||
UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin;
|
||||
containerView.layer.rasterizationScale = [[UIScreen mainScreen] scale];
|
||||
presentView.frame = (CGRect){padding, padding, presentView.bounds.size};
|
||||
[containerView addSubview:presentView];
|
||||
[viewController.view addSubview:containerView];
|
||||
self.containerView = containerView;
|
||||
|
||||
MyButton *closeButton = [[MyButton alloc] init];
|
||||
|
||||
if(self.closeButtonType == ButtonPositionTypeRight){
|
||||
CGRect closeFrame = closeButton.frame;
|
||||
closeFrame.origin.x = CGRectGetWidth(containerView.bounds)-CGRectGetWidth(closeFrame);
|
||||
closeButton.frame = closeFrame;
|
||||
}
|
||||
|
||||
[closeButton addTarget:self action:@selector(close) forControlEvents:UIControlEventTouchUpInside];
|
||||
[containerView addSubview:closeButton];
|
||||
self.closeButton = closeButton;
|
||||
[self setCloseButtonType:self.closeButtonType];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.window makeKeyAndVisible];
|
||||
if(animated){
|
||||
viewController.styleView.alpha = 0;
|
||||
[UIView animateWithDuration:kFadeInAnimationDuration animations:^{
|
||||
viewController.styleView.alpha = 1;
|
||||
}];
|
||||
containerView.alpha = 0;
|
||||
containerView.layer.shouldRasterize = YES;
|
||||
containerView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.0, 0.0);
|
||||
[UIView animateWithDuration:kTransformPart1AnimationDuration animations:^{
|
||||
containerView.alpha = 1;
|
||||
containerView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.2, 1.2);
|
||||
} completion:^(BOOL finished) {
|
||||
[UIView animateWithDuration:.2 animations:^{
|
||||
containerView.alpha = 1;
|
||||
containerView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.8, 0.8);
|
||||
} completion:^(BOOL finished) {
|
||||
[UIView animateWithDuration:kTransformPart2AnimationDuration delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
|
||||
containerView.alpha = 1;
|
||||
containerView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1, 1);
|
||||
} completion:^(BOOL finished2) {
|
||||
containerView.layer.shouldRasterize = NO;
|
||||
}];
|
||||
|
||||
}];
|
||||
}];
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
- (void)close {
|
||||
[self hideAnimated:YES withCompletionBlock:nil];
|
||||
|
||||
}
|
||||
- (void)closeWithBlcok:(void(^)())complete {
|
||||
[self hideAnimated:YES withCompletionBlock:complete];
|
||||
}
|
||||
|
||||
- (void)hideAnimated:(BOOL)animated withCompletionBlock:(void(^)())completion {
|
||||
if(!animated){
|
||||
[self cleanup];
|
||||
return;
|
||||
}
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[UIView animateWithDuration:kFadeInAnimationDuration animations:^{
|
||||
self.viewController.styleView.alpha = 0;
|
||||
}];
|
||||
|
||||
self.containerView.layer.shouldRasterize = YES;
|
||||
[UIView animateWithDuration:kTransformPart2AnimationDuration animations:^{
|
||||
self.containerView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.2, 0.2);
|
||||
|
||||
|
||||
} completion:^(BOOL finished){
|
||||
[UIView animateWithDuration:kTransformPart1AnimationDuration delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
|
||||
self.containerView.alpha = 0;
|
||||
self.containerView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.0, 0.0);
|
||||
} completion:^(BOOL finished2){
|
||||
[self cleanup];
|
||||
if(completion){
|
||||
completion();
|
||||
}
|
||||
}];
|
||||
}];
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
- (void)cleanup{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[self.containerView removeFromSuperview];
|
||||
[[[[UIApplication sharedApplication] delegate] window] makeKeyWindow];
|
||||
[self.window removeFromSuperview];
|
||||
self.contentViewController = nil;
|
||||
self.window = nil;
|
||||
}
|
||||
- (void)dealloc{
|
||||
|
||||
[self cleanup];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* 自定义的VC
|
||||
*/
|
||||
@implementation MyViewController
|
||||
|
||||
- (void)loadView {
|
||||
self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
self.view.backgroundColor = [UIColor clearColor];
|
||||
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
|
||||
|
||||
shadeView *styleView = [[shadeView alloc] initWithFrame:self.view.bounds];
|
||||
styleView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
|
||||
styleView.opaque = NO;
|
||||
[self.view addSubview:styleView];
|
||||
self.styleView = styleView;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* 自定义的View
|
||||
*/
|
||||
@implementation MyView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
|
||||
self = [super initWithFrame:frame];
|
||||
if (!self) {
|
||||
CALayer *styleLayer = [[CALayer alloc] init];
|
||||
styleLayer.cornerRadius = 4;
|
||||
styleLayer.shadowColor= [[UIColor whiteColor] CGColor];
|
||||
styleLayer.shadowOffset = CGSizeMake(0, 0);
|
||||
styleLayer.shadowOpacity = 0.5;
|
||||
styleLayer.borderWidth = 1;
|
||||
styleLayer.borderColor = [[UIColor whiteColor] CGColor];
|
||||
styleLayer.frame = CGRectInset(self.bounds, 12, 12);
|
||||
[self.layer addSublayer:styleLayer];
|
||||
self.styleLayer = styleLayer;
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setPopBackgroundColor:(UIColor *)popBackgroundColor {
|
||||
if(_popBackgroundColor != popBackgroundColor){
|
||||
_popBackgroundColor = popBackgroundColor;
|
||||
self.styleLayer.backgroundColor = [popBackgroundColor CGColor];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
//遮罩
|
||||
@implementation shadeView
|
||||
|
||||
- (void)drawRect:(CGRect)rect{
|
||||
CGContextRef context = UIGraphicsGetCurrentContext();
|
||||
|
||||
if ([LXADViewTool sharedInstance].shadeBackgroundType == ShadeBackgroundTypeSolid) {
|
||||
[[UIColor colorWithWhite:0 alpha:0.55] set];
|
||||
CGContextFillRect(context, self.bounds);
|
||||
} else {
|
||||
CGContextSaveGState(context);
|
||||
size_t gradLocationsNum = 2;
|
||||
CGFloat gradLocations[2] = {0.0f, 1.0f};
|
||||
CGFloat gradColors[8] = {0, 0, 0, 0.3, 0, 0, 0, 0.8};
|
||||
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
|
||||
CGGradientRef gradient = CGGradientCreateWithColorComponents(colorSpace, gradColors, gradLocations, gradLocationsNum);
|
||||
CGColorSpaceRelease(colorSpace), colorSpace = NULL;
|
||||
CGPoint gradCenter= CGPointMake(round(CGRectGetMidX(self.bounds)), round(CGRectGetMidY(self.bounds)));
|
||||
CGFloat gradRadius = MAX(CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds));
|
||||
CGContextDrawRadialGradient(context, gradient, gradCenter, 0, gradCenter, gradRadius, kCGGradientDrawsAfterEndLocation);
|
||||
CGGradientRelease(gradient), gradient = NULL;
|
||||
CGContextRestoreGState(context);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
if ([LXADViewTool sharedInstance].tapOutsideToDismiss) {
|
||||
[[LXADViewTool sharedInstance] hideAnimated:YES withCompletionBlock:nil];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
自定义的button
|
||||
|
||||
- returns: button
|
||||
*/
|
||||
@implementation MyButton
|
||||
|
||||
- (instancetype)init {
|
||||
|
||||
self = [super initWithFrame:(CGRect){0, 0, 32, 32}];
|
||||
if (self) {
|
||||
|
||||
[self setBackgroundImage:[UIImage imageNamed:@"red_packge_close"] forState:UIControlStateNormal];
|
||||
// self.backgroundColor = [UIColor greenColor];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// NSString+JSON.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/10/12.
|
||||
// Copyright © 2016年 lianxiang. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSString (JSON)
|
||||
|
||||
-(NSDictionary *)parseJSONStringToNSDictionary:(NSString *)JSONString;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// NSString+JSON.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/10/12.
|
||||
// Copyright © 2016年 lianxiang. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSString+JSON.h"
|
||||
|
||||
@implementation NSString (JSON)
|
||||
|
||||
-(NSDictionary *)parseJSONStringToNSDictionary:(NSString *)JSONString{
|
||||
|
||||
NSData *JSONData = [JSONString dataUsingEncoding:NSUTF8StringEncoding];
|
||||
NSDictionary *responseJSON = [NSJSONSerialization JSONObjectWithData:JSONData options:NSJSONReadingMutableLeaves error:nil];
|
||||
return responseJSON;
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// NSTimer+Convenience.h
|
||||
// ISCTest
|
||||
//
|
||||
// Created by imac on 16/3/23.
|
||||
// Copyright © 2016年 xiang. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSTimer (Convenience)
|
||||
typedef void (^LXVoidBlock)(void);
|
||||
|
||||
/**
|
||||
* 创建Timer---Block版本
|
||||
*
|
||||
* @param interval 每隔interval秒就回调一次callback
|
||||
* @param repeats 是否重复
|
||||
* @param callback 回调block
|
||||
*
|
||||
* @return NSTimer对象
|
||||
*/
|
||||
+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)interval
|
||||
repeats:(BOOL)repeats
|
||||
callback:(LXVoidBlock)callback;
|
||||
|
||||
/**
|
||||
* 创建Timer---Block版本
|
||||
*
|
||||
* @param interval 每隔interval秒就回调一次callback
|
||||
* @param count 回调多少次后自动暂停,如果count <= 0,则表示无限次,否则表示具体的次数
|
||||
* @param callback 回调block
|
||||
*
|
||||
* @return NSTimer对象
|
||||
*/
|
||||
+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)interval
|
||||
count:(NSInteger)count
|
||||
callback:(LXVoidBlock)callback;
|
||||
/**
|
||||
* 开始启动定时器
|
||||
*/
|
||||
- (void)fireTimer;
|
||||
|
||||
/**
|
||||
* 暂停定时器
|
||||
*/
|
||||
- (void)unfireTimer;
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,78 @@
|
||||
//
|
||||
// NSTimer+Convenience.m
|
||||
// ISCTest
|
||||
//
|
||||
// Created by imac on 16/3/23.
|
||||
// Copyright © 2016年 xiang. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSTimer+Convenience.h"
|
||||
|
||||
@implementation NSTimer (Convenience)
|
||||
|
||||
+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)interval
|
||||
repeats:(BOOL)repeats
|
||||
callback:(LXVoidBlock)callback {
|
||||
return [NSTimer scheduledTimerWithTimeInterval:interval
|
||||
target:self
|
||||
selector:@selector(onTimerUpdateBlock:)
|
||||
userInfo:[callback copy]
|
||||
repeats:repeats];
|
||||
}
|
||||
|
||||
+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)interval
|
||||
count:(NSInteger)count
|
||||
callback:(LXVoidBlock)callback {
|
||||
NSDictionary *userInfo = @{@"callback" : [callback copy],
|
||||
@"count" : @(count)};
|
||||
return [NSTimer scheduledTimerWithTimeInterval:interval
|
||||
target:self
|
||||
selector:@selector(onTimerUpdateCountBlock:)
|
||||
userInfo:userInfo
|
||||
repeats:YES];
|
||||
}
|
||||
|
||||
+ (void)onTimerUpdateBlock:(NSTimer *)timer {
|
||||
LXVoidBlock block = timer.userInfo;
|
||||
|
||||
if (block) {
|
||||
block();
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)onTimerUpdateCountBlock:(NSTimer *)timer {
|
||||
static NSUInteger currentCount = 0;
|
||||
|
||||
NSDictionary *userInfo = timer.userInfo;
|
||||
LXVoidBlock callback = userInfo[@"callback"];
|
||||
NSNumber *count = userInfo[@"count"];
|
||||
|
||||
if (count.integerValue <= 0) {
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
} else {
|
||||
if (currentCount < count.integerValue) {
|
||||
currentCount++;
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
} else {
|
||||
currentCount = 0;
|
||||
|
||||
[timer unfireTimer];
|
||||
[timer invalidate];
|
||||
timer = nil;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)fireTimer {
|
||||
[self setFireDate:[NSDate distantPast]];
|
||||
}
|
||||
|
||||
- (void)unfireTimer {
|
||||
[self setFireDate:[NSDate distantFuture]];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// UIControl+YT.h
|
||||
// CollectionViewTest
|
||||
//
|
||||
// Created by imac on 17/3/1.
|
||||
// Copyright © 2017年 xiang. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
//防止按钮多次点击 runtime 方式
|
||||
@interface UIControl (YT)
|
||||
@property (nonatomic,assign) NSTimeInterval yt_acceptEventInterval;
|
||||
@property (nonatomic, assign) BOOL yt_ignoreEvent;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// UIControl+YT.m
|
||||
// CollectionViewTest
|
||||
//
|
||||
// Created by imac on 17/3/1.
|
||||
// Copyright © 2017年 xiang. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UIControl+YT.h"
|
||||
#import <objc/runtime.h>
|
||||
@implementation UIControl (YT)
|
||||
|
||||
static const char *UIControl_acceptEventInterval = "UIControl_acceptEventInterval";
|
||||
|
||||
static const char *UIcontrol_ignoreEvent = "UIcontrol_ignoreEvent";
|
||||
|
||||
- (NSTimeInterval)yt_acceptEventInterval {
|
||||
|
||||
return [objc_getAssociatedObject(self, UIControl_acceptEventInterval) doubleValue];
|
||||
|
||||
}
|
||||
|
||||
- (void)setYt_acceptEventInterval:(NSTimeInterval)yt_acceptEventInterval {
|
||||
|
||||
objc_setAssociatedObject(self, UIControl_acceptEventInterval, @(yt_acceptEventInterval), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
|
||||
}
|
||||
|
||||
- (BOOL)yt_ignoreEvent {
|
||||
|
||||
return [objc_getAssociatedObject(self, UIcontrol_ignoreEvent) boolValue];
|
||||
|
||||
}
|
||||
|
||||
- (void)setYt_ignoreEvent:(BOOL)yt_ignoreEvent {
|
||||
|
||||
objc_setAssociatedObject(self, UIcontrol_ignoreEvent, @(yt_ignoreEvent), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
|
||||
}
|
||||
|
||||
+ (void)load {
|
||||
|
||||
Method a = class_getInstanceMethod(self, @selector(sendAction:to:forEvent:));
|
||||
|
||||
Method b = class_getInstanceMethod(self, @selector(__yt_sendAction:to:forEvent:));
|
||||
|
||||
method_exchangeImplementations(a, b);
|
||||
|
||||
}
|
||||
|
||||
- (void)__yt_sendAction:(SEL)action to:(id)target forEvent:(UIEvent *)event {
|
||||
|
||||
if (self.yt_ignoreEvent) return;
|
||||
|
||||
if (self.yt_acceptEventInterval > 0) {
|
||||
|
||||
self.yt_ignoreEvent = YES;
|
||||
|
||||
[self performSelector:@selector(setYt_ignoreEvent:) withObject:@(NO) afterDelay:self.yt_acceptEventInterval];
|
||||
|
||||
}
|
||||
|
||||
[self __yt_sendAction:action to:target forEvent:event];
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// UINavigationBar+Background.h
|
||||
// CustomNavicationController
|
||||
//
|
||||
// Created by YiJiang Chen on 15/10/22.
|
||||
// Copyright (c) 2015年 YiJiang Chen. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface UINavigationBar (Background)
|
||||
- (void)cnSetBackgroundColor:(UIColor *)backgroundColor;
|
||||
- (void)cnReset;
|
||||
//设置透明导航
|
||||
-(void)setClearNav;
|
||||
|
||||
-(void)resetBackgroundImage;
|
||||
|
||||
-(void)setWhiteNav;
|
||||
|
||||
|
||||
@end
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// UINavigationBar+Background.m
|
||||
// CustomNavicationController
|
||||
//
|
||||
// Created by YiJiang Chen on 15/10/22.
|
||||
// Copyright (c) 2015年 YiJiang Chen. All rights reserved.
|
||||
//
|
||||
#import <objc/runtime.h>
|
||||
#import "UINavigationBar+Background.h"
|
||||
|
||||
@implementation UINavigationBar (Background)
|
||||
static char overlayKey;
|
||||
|
||||
- (UIView *)overlay
|
||||
{
|
||||
return objc_getAssociatedObject(self, &overlayKey);
|
||||
}
|
||||
|
||||
- (void)setOverlay:(UIView *)overlay
|
||||
{
|
||||
objc_setAssociatedObject(self, &overlayKey, overlay, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
|
||||
- (void)cnSetBackgroundColor:(UIColor *)backgroundColor
|
||||
{
|
||||
if (!self.overlay) {
|
||||
[self setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
|
||||
self.overlay = [[UIView alloc] initWithFrame:CGRectMake(0, -20, [UIScreen mainScreen].bounds.size.width, CGRectGetHeight(self.bounds) + 20)];
|
||||
self.overlay.userInteractionEnabled = NO;
|
||||
self.overlay.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
|
||||
[self insertSubview:self.overlay atIndex:0];
|
||||
}
|
||||
|
||||
self.overlay.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
- (void)cnReset
|
||||
{
|
||||
|
||||
[self setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
|
||||
[self.overlay removeFromSuperview];
|
||||
self.overlay = nil;
|
||||
}
|
||||
|
||||
-(void)setClearNav
|
||||
{
|
||||
|
||||
[self setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
|
||||
//设置那条横线直接隐藏
|
||||
self.shadowImage = [[UIImage alloc] init];
|
||||
if (self.overlay) {
|
||||
[self.overlay removeFromSuperview];
|
||||
self.overlay = nil;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-(void)resetBackgroundImage{
|
||||
|
||||
[self setBackgroundImage:[UIImage imageNamed:@"blackbar.png"] forBarMetrics:UIBarMetricsDefault];
|
||||
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];
|
||||
|
||||
}
|
||||
|
||||
-(void)setWhiteNav
|
||||
{
|
||||
[self setBackgroundImage:[UIImage imageNamed:@"blackbar_white.png"] forBarMetrics:UIBarMetricsDefault];
|
||||
|
||||
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:NO];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// UITabBar+addRedPointBadge.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 17/3/17.
|
||||
// Copyright © 2017年 lianlian. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface UITabBar (addRedPointBadge)
|
||||
- (void)showBadgeOnItemIndex:(int)index;
|
||||
- (void)hideBadgeOnItemIndex:(int)index;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// UITabBar+addRedPointBadge.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 17/3/17.
|
||||
// Copyright © 2017年 lianlian. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UITabBar+addRedPointBadge.h"
|
||||
#define IFISHITEMNUNBERS 4.0
|
||||
@implementation UITabBar (addRedPointBadge)
|
||||
- (void)showBadgeOnItemIndex:(int)index{
|
||||
|
||||
//移除之前的小红点
|
||||
[self removeBadgeOnItemIndex:index];
|
||||
|
||||
UIView *badgeView = [[UIView alloc]init];
|
||||
badgeView.tag = 888 + index;
|
||||
badgeView.backgroundColor = RGB(252, 89, 89);
|
||||
CGRect tabFrame = self.frame;
|
||||
|
||||
//确定小红点的位置
|
||||
float percentX = (index +0.55) / IFISHITEMNUNBERS;
|
||||
CGFloat x = ceilf(percentX * tabFrame.size.width);
|
||||
CGFloat y = ceilf(0.1 * tabFrame.size.height);
|
||||
badgeView.frame = CGRectMake(x, y, 8, 8);
|
||||
badgeView.layer.cornerRadius = badgeView.frame.size.width/2;
|
||||
|
||||
[self addSubview:badgeView];
|
||||
[self bringSubviewToFront:badgeView];
|
||||
|
||||
}
|
||||
|
||||
- (void)hideBadgeOnItemIndex:(int)index{
|
||||
|
||||
//移除小红点
|
||||
[self removeBadgeOnItemIndex:index];
|
||||
|
||||
}
|
||||
|
||||
- (void)removeBadgeOnItemIndex:(int)index{
|
||||
|
||||
//按照tag值进行移除
|
||||
for (UIView *subView in self.subviews) {
|
||||
if (subView.tag == 888+index) {
|
||||
[subView removeFromSuperview];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// UITextField+KeyBordDoneView.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 17/2/15.
|
||||
// Copyright © 2017年 lianlian. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface UITextField (KeyBordDoneView)
|
||||
-(void)keybordViewAddDoneView;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// UITextField+KeyBordDoneView.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 17/2/15.
|
||||
// Copyright © 2017年 lianlian. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UITextField+KeyBordDoneView.h"
|
||||
|
||||
@implementation UITextField (KeyBordDoneView)
|
||||
-(void)keybordViewAddDoneView
|
||||
{
|
||||
UIToolbar * topView = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 30)];
|
||||
[topView setBarStyle:UIBarStyleBlackTranslucent];
|
||||
|
||||
UIBarButtonItem * btnSpace = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
|
||||
|
||||
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
btn.frame = CGRectMake(2, 5, 50, 25);
|
||||
[btn addTarget:self action:@selector(dismissKeyBoard) forControlEvents:UIControlEventTouchUpInside];
|
||||
// [btn setImage:[UIImage imageNamed:@"shouqi"] forState:UIControlStateNormal];
|
||||
[btn setTitle:@"完成" forState:UIControlStateNormal];
|
||||
UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc]initWithCustomView:btn];
|
||||
NSArray * buttonsArray = [NSArray arrayWithObjects:btnSpace,doneBtn,nil];
|
||||
[topView setItems:buttonsArray];
|
||||
[self setInputAccessoryView:topView];
|
||||
|
||||
}
|
||||
|
||||
-(void)dismissKeyBoard
|
||||
{
|
||||
|
||||
[self resignFirstResponder];
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// UITextView+AddKeybordDoneVIew.h
|
||||
// KeyBordViewExtern
|
||||
//
|
||||
// Created by imac on 16/11/21.
|
||||
// Copyright © 2016年 xiang. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface UITextView (AddKeybordDoneVIew)
|
||||
|
||||
-(void)keybordViewAddDoneView;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// UITextView+AddKeybordDoneVIew.m
|
||||
// KeyBordViewExtern
|
||||
//
|
||||
// Created by imac on 16/11/21.
|
||||
// Copyright © 2016年 xiang. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UITextView+AddKeybordDoneVIew.h"
|
||||
|
||||
@implementation UITextView (AddKeybordDoneVIew)
|
||||
|
||||
-(void)keybordViewAddDoneView
|
||||
{
|
||||
UIToolbar * topView = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 30)];
|
||||
[topView setBarStyle:UIBarStyleBlackTranslucent];
|
||||
|
||||
UIBarButtonItem * btnSpace = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
|
||||
|
||||
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
btn.frame = CGRectMake(2, 5, 50, 25);
|
||||
[btn addTarget:self action:@selector(dismissKeyBoard) forControlEvents:UIControlEventTouchUpInside];
|
||||
// [btn setImage:[UIImage imageNamed:@"shouqi"] forState:UIControlStateNormal];
|
||||
[btn setTitle:@"完成" forState:UIControlStateNormal];
|
||||
UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc]initWithCustomView:btn];
|
||||
NSArray * buttonsArray = [NSArray arrayWithObjects:btnSpace,doneBtn,nil];
|
||||
[topView setItems:buttonsArray];
|
||||
[self setInputAccessoryView:topView];
|
||||
|
||||
}
|
||||
|
||||
-(void)dismissKeyBoard
|
||||
{
|
||||
|
||||
[self resignFirstResponder];
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user