【iOS 知识汇】drawrect ->android (ondraw)

//

//  DMView.m

//  ZolSoft

//

//  Created by zol_app on 2022/7/28.

//

 

#import "DMView.h"

@interface DMView(){

    NSString* _useLightText;

    CGFloat start_x ;

    CGFloat start_x1 ;

 

}

@property (nonatomic, strong) NSTimer *timer;

@end

@implementation DMView

 

- (instancetype)initWithFrame:(CGRect)frame{

    self = [super initWithFrame:frame];

    if(self){

        _useLightText = @"如何使用LotusScript代理来发送HTML格式的邮件";

        start_x = 0;

        start_x1 =800;

        [self initTimer];

    }

    return self ;

    

}

 

-(void)initTimer{

    MJWeakSelf;

    self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0/60 repeats:YES block:^(NSTimer * _Nonnull timer) {

        [weakSelf setNeedsDisplay];

    }];

    

}

 

- (void)drawRect:(CGRect)rect{

    

    UIFont *font = [UIFont boldSystemFontOfSize:14];

    NSDictionary *attributes = nil;

    attributes = [NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, [UIColor redColor], NSForegroundColorAttributeName, nil];

    [_useLightText drawAtPoint:CGPointMake(start_x, 100) withAttributes:attributes];

    [_useLightText drawAtPoint:CGPointMake(start_x1, 130) withAttributes:attributes];

    start_x+=1;

    start_x1-=2;

    if(start_x>kScreenWidth){

        start_x = 0;

    }

    if(start_x1<-200){

        start_x1 = kScreenWidth;

    }

}

 

@end

posted on 2022-07-29 10:01  wp7ers  阅读(38)  评论(0)    收藏  举报