封装了一个继承于UIView的类,如下:
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XtayNoticeScrollView : UIView
- (instancetype)initWithFrame:(CGRect)frame titleArray:(NSArray<NSString *> *)titleArray;
- (void)openTimer;
- (void)closeTimer;
@end
NS_ASSUME_NONNULL_END
#define ROW_H self.bounds.size.height
#import "XtayNoticeScrollView.h"
@interface XtayNoticeScrollView ()
/// scrollView
@property (nonatomic, strong) UIScrollView *bgScrollView;
/// titleArr
@property (nonatomic, copy) NSArray *titleArr;
/// timer
@property (nonatomic, strong) NSTimer *scrollTimer;
@end
@implementation XtayNoticeScrollView
- (instancetype)initWithFrame:(CGRect)frame titleArray:(NSArray<NSString *> *)titleArray {
self = [super initWithFrame:frame];
if (self) {
self.titleArr = titleArray;
[self addSubview:self.bgScrollView];
[self cr