2018-12-25横向无限自动移动


#import "recFifCell.h"
#define yis 0.2
#define ScreenWidth [UIScreen mainScreen].bounds.size.width
#define ScreenHeight  [UIScreen mainScreen].bounds.size.height
@interface recFifCell()
{
    int number;
}
@property(nonatomic,strong)UIView *bgview;
@property(nonatomic,strong)UIView *oenView;
@property(nonatomic,strong)UIView *towView;
@property(nonatomic,strong)UIView *oensView;
@property(nonatomic,strong)UIView *towsView;
@property (nonatomic,strong)CADisplayLink *displayLink;
@property(nonatomic,strong)NSArray *imgArr;
@property(nonatomic,strong)NSArray *titleArr;
@end

@implementation recFifCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
      
        self.bgview = [[UIView alloc]initWithFrame:CGRectMake(20, 0, ScreenWidth-40, 280)];
        self.bgview.layer.masksToBounds=YES;
        self.bgview.layer.cornerRadius=10;
        self.bgview.backgroundColor = [UIColor grayColor];
        [self addSubview:self.bgview];
        
        self.imgArr = @[@"jiangzhe1",@"jiangzhe2",@"jiangzhe3",@"jiangzhe4"];
        self.titleArr = @[@"虞姬",@"猴子",@"凯",@"貂蝉"];
        number = (int)self.imgArr.count;
        [self addview];
        _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(rotate)];
        _displayLink.frameInterval = 3.0;
        [_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
    }
    return self;
}
-(void)addview{
    
    self.oenView = [[UIView alloc]init];
    [self.bgview addSubview:self.oenView];
    self.towView = [[UIView alloc]init];
    [self.bgview addSubview:self.towView];
    

    self.oensView = [[UIView alloc]init];
    [self.bgview addSubview:self.oensView];
    self.towsView = [[UIView alloc]init];
    [self.bgview addSubview:self.towsView];
    
    
    
    
    for (int a=0; a ScreenWidth+10.000000) {
        self.oensView.frame = CGRectMake(self.towsView.frame.origin.x-self.oensView.frame.size.width, 140, self.oensView.frame.size.width, 140);
    }
    if (self.towsView.frame.origin.x > ScreenWidth+10.000000) {
        self.towsView.frame = CGRectMake(self.oensView.frame.origin.x-self.towsView.frame.size.width, 140, self.towsView.frame.size.width, 140);
    }
    
    

    
}
#pragma mark --- 定时器销毁
- (void)invalidate {
    if (!_displayLink) {
        [_displayLink invalidate];
        _displayLink = nil;
    }
}
-(void)dealloc{
    if (_displayLink) {
        [_displayLink invalidate];
        _displayLink = nil;
    }
}


你可能感兴趣的:(2018-12-25横向无限自动移动)