Initial commit

This commit is contained in:
ifish
2017-08-15 16:59:01 +08:00
commit bdc83e07ef
5766 changed files with 423223 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
//
// GYChangeTextView.h
// GYShop
//
// Created by mac on 16/6/13.
// Copyright © 2016年 GY. All rights reserved.
//
#import <UIKit/UIKit.h>
@class GYChangeTextView;
@protocol GYChangeTextViewDelegate <NSObject>
- (void)gyChangeTextView:(GYChangeTextView *)textView didTapedAtIndex:(NSInteger)index;
@end
@interface GYChangeTextView : UIView
@property (nonatomic, assign) id<GYChangeTextViewDelegate> delegate;
- (void)animationWithTexts:(NSArray *)textAry;
- (void)stopAnimation;
-(void)startTextAnimation;
@end
+127
View File
@@ -0,0 +1,127 @@
//
// GYChangeTextView.m
// GYShop
//
// Created by mac on 16/6/13.
// Copyright © 2016年 GY. All rights reserved.
//
#import "GYChangeTextView.h"
static const CGFloat DealyWhenTileInMiddle = 3.0;
static const CGFloat DealyWhenTileInBottom = 0.0;
#define IifshAnimationTextColor [UIColor colorWithRed:153.0/256.0 green:153.0/256.0 blue:153.0/256.0 alpha:1]
typedef NS_ENUM(NSUInteger, GYTitlePosition) {
GYTitlePositionTop = 1,
GYTitlePositionMiddle = 2,
GYTitlePositionBottom = 3
};
@interface GYChangeTextView ()
@property (nonatomic, strong) UILabel *textLabel;
@property (nonatomic, strong) NSArray *contentsAry;
@property (nonatomic, assign) CGPoint topPosition;
@property (nonatomic, assign) CGPoint middlePosition;
@property (nonatomic, assign) CGPoint bottomPosition;
/*
*1.控制延迟时间,当文字在中间时,延时时间长一些,如5秒,这样可以让用户浏览清楚内容;
*2.当文字隐藏在底部的时候,不需要延迟,这样衔接才流畅;
*3.通过上面的静态变量更改需要的值
*/
@property (nonatomic, assign) CGFloat needDealy;
@property (nonatomic, assign) NSInteger currentIndex; /*当前播放到那个标题了*/
@property (nonatomic, assign) BOOL shouldStop; /*是否停止*/
@end
@implementation GYChangeTextView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.topPosition = CGPointMake(self.frame.size.width/2, -self.frame.size.height/2);
self.middlePosition = CGPointMake(self.frame.size.width/2, self.frame.size.height/2);
self.bottomPosition = CGPointMake(self.frame.size.width/2, self.frame.size.height/2*3);
//self.shouldStop = NO;
_textLabel = [[UILabel alloc] init];
_textLabel.layer.bounds = CGRectMake(0, 0, CGRectGetWidth(frame), CGRectGetHeight(frame));
_textLabel.layer.position = self.middlePosition;
_textLabel.textAlignment = NSTextAlignmentCenter;
_textLabel.textColor = IifshAnimationTextColor;
[self addSubview:_textLabel];
self.clipsToBounds = YES; /*保证文字不跑出视图*/
self.needDealy = DealyWhenTileInMiddle; /*控制第一次显示时间*/
self.currentIndex = 0;
}
return self;
}
- (void)animationWithTexts:(NSArray *)textAry {
self.contentsAry = textAry;
self.textLabel.text = [textAry objectAtIndex:0];
}
-(void)startTextAnimation
{
self.shouldStop = NO;
[self startAnimation];
}
- (void)startAnimation {
__weak typeof(self) weakSelf = self;
[UIView animateWithDuration:0.3 delay:self.needDealy options:UIViewAnimationOptionCurveEaseInOut animations:^{
if ([weakSelf currentTitlePosition] == GYTitlePositionMiddle) {
weakSelf.textLabel.layer.position = weakSelf.topPosition;
} else if ([weakSelf currentTitlePosition] == GYTitlePositionBottom) {
weakSelf.textLabel.layer.position = weakSelf.middlePosition;
}
} completion:^(BOOL finished) {
if ([weakSelf currentTitlePosition] == GYTitlePositionTop) {
weakSelf.textLabel.layer.position = weakSelf.bottomPosition;
weakSelf.needDealy = DealyWhenTileInBottom;
weakSelf.currentIndex ++;
weakSelf.textLabel.text = [weakSelf.contentsAry objectAtIndex:[weakSelf realCurrentIndex]];
} else {
weakSelf.needDealy = DealyWhenTileInMiddle;
}
if (!weakSelf.shouldStop) {
[weakSelf startAnimation];
} else { //停止动画后,要设置label位置和label显示内容
weakSelf.textLabel.layer.position = weakSelf.middlePosition;
weakSelf.textLabel.text = [weakSelf.contentsAry objectAtIndex:[weakSelf realCurrentIndex]];
}
}];
}
- (void)stopAnimation {
self.shouldStop = YES;
self.currentIndex = 0;
_textLabel.layer.position = self.middlePosition;
}
- (NSInteger)realCurrentIndex {
return self.currentIndex % [self.contentsAry count];
}
- (GYTitlePosition)currentTitlePosition {
if (self.textLabel.layer.position.y == self.topPosition.y) {
return GYTitlePositionTop;
} else if (self.textLabel.layer.position.y == self.middlePosition.y) {
return GYTitlePositionMiddle;
}
return GYTitlePositionBottom;
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
if ([self.delegate respondsToSelector:@selector(gyChangeTextView:didTapedAtIndex:)]) {
[self.delegate gyChangeTextView:self didTapedAtIndex:[self realCurrentIndex]];
}
}
@end
@@ -0,0 +1,19 @@
//
// IfishConnectingView.h
// Ifish
//
// Created by imac on 16/10/31.
// Copyright © 2016年 lianxiang. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "GYChangeTextView.h"
@interface IfishConnectingView : UIView <GYChangeTextViewDelegate>
@property (nonatomic,strong) GYChangeTextView *textChangeView;
@property (nonatomic,strong) UIImageView *fishImageView ;
@property (nonatomic,strong) UIImageView *lineView;
@end
@@ -0,0 +1,117 @@
//
// IfishConnectingView.m
// Ifish
//
// Created by imac on 16/10/31.
// Copyright © 2016年 lianxiang. All rights reserved.
//
#import "IfishConnectingView.h"
#import "GYChangeTextView.h"
#import "FBShimmeringView.h"
@implementation IfishConnectingView
-(id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
[self setUpVewsWithframe:frame];
}
return self;
}
-(void)setUpVewsWithframe:(CGRect)frame
{
CGFloat percentWH = 0.14;//6p 64/414
CGFloat ImgW =frame.size.width*percentWH;
self.fishImageView = [[UIImageView alloc] initWithFrame:CGRectMake(frame.size.width/2 - ImgW/2,10,ImgW, ImgW)];
self.fishImageView.image = [UIImage imageNamed:@"linkingdevice_logo"];
[self addSubview:self.fishImageView];
GYChangeTextView *tView = [[GYChangeTextView alloc] initWithFrame:CGRectMake(0,CGRectGetMaxY(self.fishImageView.frame)+10,frame.size.width, 30)];
tView.delegate = self;
//tView.layer.borderWidth = 1.0; /*为了看的清楚加个边*/
//tView.layer.borderColor = [UIColor blackColor].CGColor;
[self addSubview:tView];
self.textChangeView = tView;
// [self.textChangeView startAnimation];
//1pexView
self.lineView=[[UIImageView alloc] initWithFrame:CGRectMake(20 ,CGRectGetMaxY(self.textChangeView.frame) + 5,frame.size.width - 20*2,1)];
self.lineView.image = [UIImage imageNamed:@"linkingdevice_line"];
[self addSubview:self.lineView];
[self setShimmigViewfishImage:self.fishImageView];
[self setShimmigViewlineView:self.lineView];
}
-(void)setShimmigViewfishImage:(UIImageView *)shimmView
{
FBShimmeringView *shimmeringView = [[FBShimmeringView alloc] initWithFrame:shimmView.frame];
shimmeringView.shimmering = YES;
shimmeringView.shimmeringOpacity = 1;
shimmeringView.shimmeringAnimationOpacity = 0.3;
shimmeringView.shimmeringDirection = FBShimmerDirectionRight;
//self.shimmeringView.shimmeringBeginFadeDuration = 1;
shimmeringView.shimmeringPauseDuration = 0.8;
shimmeringView.shimmeringHighlightLength = 0.8;
shimmeringView.shimmeringHighlightWidth = 0.8;
shimmeringView.shimmeringSpeed = 100;
//self.shimmeringView.backgroundColor = [UIColor whiteColor];
//self.shimmeringView.clipsToBounds = YES;
[self addSubview:shimmeringView];
shimmeringView.contentView = shimmView;
}
-(void)setShimmigViewlineView:(UIImageView *)shimmView
{
FBShimmeringView *shimmeringView = [[FBShimmeringView alloc] initWithFrame:shimmView.frame];
shimmeringView.shimmering = YES;
shimmeringView.shimmeringOpacity = 1;
shimmeringView.shimmeringAnimationOpacity = 0.7;
shimmeringView.shimmeringDirection = FBShimmerDirectionRight;
//self.shimmeringView.shimmeringBeginFadeDuration = 1;
shimmeringView.shimmeringPauseDuration = 0.8;
shimmeringView.shimmeringHighlightLength = 0.5;
shimmeringView.shimmeringHighlightWidth = 0.5;
shimmeringView.shimmeringSpeed = 100;
//self.shimmeringView.backgroundColor = [UIColor whiteColor];
//self.shimmeringView.clipsToBounds = YES;
[self addSubview:shimmeringView];
shimmeringView.contentView = shimmView;
}
- (void)gyChangeTextView:(GYChangeTextView *)textView didTapedAtIndex:(NSInteger)index {
NSLog(@"index%ld",index);
}
@end