Skip to content

Commit ecb5ce9

Browse files
committed
Refactored some duplicate methods from our TXScrollLabelView to TXScrollLabelViewDeprecated category.
1 parent 784501f commit ecb5ce9

File tree

2 files changed

+140
-66
lines changed

2 files changed

+140
-66
lines changed

TXScrollLabelView/TXScrollLabelView.h

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// Copyright © 2016 tingxins. All rights reserved.
66
// 滚动视图
77

8-
#define TX_DEPRECATED(explain) __attribute__((deprecated(explain)))
8+
#define TX_DEPRECATED_METHODS(explain) __attribute__((deprecated(explain)))
9+
#define TX_DEPRECATED_MESSAGES(explain) __deprecated_msg(explain)
910

1011
#import <UIKit/UIKit.h>
1112
#import "UIView+TXFrame.h"
@@ -20,17 +21,17 @@ typedef NS_ENUM(NSInteger, TXScrollLabelViewType) {
2021
};
2122

2223
/*************WILL BE REMOVED IN FUTURE.********************/
23-
#pragma mark - Deprecated Property
24+
#pragma mark - Deprecated property
2425
/** Deprecated, please Use `scrollTitle` */
25-
@property (copy, nonatomic) NSString *tx_scrollTitle TX_DEPRECATED("Deprecated, please Use `scrollTitle`");
26+
@property (copy, nonatomic) NSString *tx_scrollTitle TX_DEPRECATED_METHODS("Deprecated, please Use `scrollTitle`");
2627
/** Deprecated, please Use `scrollType` */
27-
@property (assign, nonatomic) TXScrollLabelViewType tx_scrollType TX_DEPRECATED("Deprecated, please Use `scrollType`");
28+
@property (assign, nonatomic) TXScrollLabelViewType tx_scrollType TX_DEPRECATED_METHODS("Deprecated, please Use `scrollType`");
2829
/** Deprecated, please Use `scrollVelocity` */
29-
@property (assign, nonatomic) NSTimeInterval tx_scrollVelocity TX_DEPRECATED("Deprecated, please Use `scrollVelocity`");
30+
@property (assign, nonatomic) NSTimeInterval tx_scrollVelocity TX_DEPRECATED_METHODS("Deprecated, please Use `scrollVelocity`");
3031
/** Deprecated, please Use `frame` */
31-
@property (assign, nonatomic) CGRect tx_scrollContentSize TX_DEPRECATED("Deprecated, please Use `frame`");
32+
@property (assign, nonatomic) CGRect tx_scrollContentSize TX_DEPRECATED_METHODS("Deprecated, please Use `frame`");
3233
/** Deprecated, please Use `scrollTitleColor` */
33-
@property (strong, nonatomic) UIColor *tx_scrollTitleColor TX_DEPRECATED("Deprecated, please Use `scrollTitleColor`");
34+
@property (strong, nonatomic) UIColor *tx_scrollTitleColor TX_DEPRECATED_METHODS("Deprecated, please Use `scrollTitleColor`");
3435
/*************ALL ABOVE.***********************************/
3536

3637
#pragma mark - On Used Property
@@ -57,25 +58,24 @@ typedef NS_ENUM(NSInteger, TXScrollLabelViewType) {
5758
#pragma mark - Class Methods
5859

5960
- (instancetype)initWithTitle:(NSString *)scrollTitle
60-
scrollType:(TXScrollLabelViewType)scrollType
61-
scrollVelocity:(NSTimeInterval)scrollVelocity
62-
options:(UIViewAnimationOptions)options
63-
inset:(UIEdgeInsets)inset;
61+
type:(TXScrollLabelViewType)scrollType
62+
velocity:(NSTimeInterval)scrollVelocity
63+
options:(UIViewAnimationOptions)options
64+
inset:(UIEdgeInsets)inset;
6465

65-
+ (instancetype)tx_setScrollTitle:(NSString *)scrollTitle;
66+
+ (instancetype)scrollWithTitle:(NSString *)scrollTitle;
6667

67-
+ (instancetype)tx_setScrollTitle:(NSString *)scrollTitle
68-
scrollType:(TXScrollLabelViewType)scrollType;
69-
70-
+ (instancetype)tx_setScrollTitle:(NSString *)scrollTitle
71-
scrollType:(TXScrollLabelViewType)scrollType
72-
scrollVelocity:(NSTimeInterval)scrollVelocity;
68+
+ (instancetype)scrollWithTitle:(NSString *)scrollTitle
69+
type:(TXScrollLabelViewType)scrollType;
7370

74-
+ (instancetype)tx_setScrollTitle:(NSString *)scrollTitle
75-
scrollType:(TXScrollLabelViewType)scrollType
76-
scrollVelocity:(NSTimeInterval)scrollVelocity
77-
options:(UIViewAnimationOptions)options;
71+
+ (instancetype)scrollWithTitle:(NSString *)scrollTitle
72+
type:(TXScrollLabelViewType)scrollType
73+
velocity:(NSTimeInterval)scrollVelocity;
7874

75+
+ (instancetype)scrollWithTitle:(NSString *)scrollTitle
76+
type:(TXScrollLabelViewType)scrollType
77+
velocity:(NSTimeInterval)scrollVelocity
78+
options:(UIViewAnimationOptions)options;
7979

8080
/**
8181
类初始化方法
@@ -85,11 +85,11 @@ typedef NS_ENUM(NSInteger, TXScrollLabelViewType) {
8585
@param options Now, supports the types of TXScrollLabelViewTypeFlipRepeat\NoRepeat only.
8686
@param inset just edgeInset.
8787
*/
88-
+ (instancetype)tx_setScrollTitle:(NSString *)scrollTitle
89-
scrollType:(TXScrollLabelViewType)scrollType
90-
scrollVelocity:(NSTimeInterval)scrollVelocity
91-
options:(UIViewAnimationOptions)options
92-
inset:(UIEdgeInsets)inset;
88+
+ (instancetype)scrollWithTitle:(NSString *)scrollTitle
89+
type:(TXScrollLabelViewType)scrollType
90+
velocity:(NSTimeInterval)scrollVelocity
91+
options:(UIViewAnimationOptions)options
92+
inset:(UIEdgeInsets)inset;
9393

9494
#pragma mark - Operation Methods
9595
/**
@@ -107,3 +107,26 @@ typedef NS_ENUM(NSInteger, TXScrollLabelViewType) {
107107
- (void) pauseScrolling;
108108

109109
@end
110+
111+
@interface TXScrollLabelView (TXScrollLabelViewDeprecated)
112+
113+
+ (instancetype)tx_setScrollTitle:(NSString *)scrollTitle TX_DEPRECATED_MESSAGES("Method deprecated. Use `+ scrollWithTitle:`");
114+
115+
+ (instancetype)tx_setScrollTitle:(NSString *)scrollTitle
116+
scrollType:(TXScrollLabelViewType)scrollType TX_DEPRECATED_MESSAGES("Method deprecated. Use `+ scrollWithTitle:type:`");
117+
118+
+ (instancetype)tx_setScrollTitle:(NSString *)scrollTitle
119+
scrollType:(TXScrollLabelViewType)scrollType
120+
scrollVelocity:(NSTimeInterval)scrollVelocity TX_DEPRECATED_MESSAGES("Method deprecated. Use `+ scrollWithTitle:type:velocity:`");
121+
122+
+ (instancetype)tx_setScrollTitle:(NSString *)scrollTitle
123+
scrollType:(TXScrollLabelViewType)scrollType
124+
scrollVelocity:(NSTimeInterval)scrollVelocity
125+
options:(UIViewAnimationOptions)options TX_DEPRECATED_MESSAGES("Method deprecated. Use `+ scrollWithTitle:type:velocity:options:`");
126+
127+
+ (instancetype)tx_setScrollTitle:(NSString *)scrollTitle
128+
scrollType:(TXScrollLabelViewType)scrollType
129+
scrollVelocity:(NSTimeInterval)scrollVelocity
130+
options:(UIViewAnimationOptions)options
131+
inset:(UIEdgeInsets)inset TX_DEPRECATED_MESSAGES("Method deprecated. Use `+ scrollWithTitle:type:velocity:options:inset:`");
132+
@end

TXScrollLabelView/TXScrollLabelView.m

Lines changed: 90 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ - (void)setSomeSubviews {
130130
}
131131

132132
#pragma mark - init Methods
133-
/** Terminating app due to uncaught exception 'Warning TXScrollLabelView -[TXScrollLabelView init] unimplemented!', reason: 'unimplemented, use - tx_setScrollTitle:scrollType:scrollVelocity:options:'*/
133+
/** Terminating app due to uncaught exception 'Warning TXScrollLabelView -[TXScrollLabelView init] unimplemented!', reason: 'unimplemented, use - scrollWithTitle:scrollType:scrollVelocity:options:'*/
134134
- (instancetype)init {
135-
@throw [NSException exceptionWithName:[NSString stringWithFormat:@"Warning %@ %s unimplemented!", self.class, __func__] reason:@"unimplemented, please use - tx_setScrollTitle:scrollType:scrollVelocity:options:" userInfo:nil];
135+
@throw [NSException exceptionWithName:[NSString stringWithFormat:@"Warning %@ %s unimplemented!", self.class, __func__] reason:@"unimplemented, please use - scrollWithTitle:scrollType:scrollVelocity:options:" userInfo:nil];
136136
}
137137

138138
- (instancetype)initWithFrame:(CGRect)frame {
@@ -146,10 +146,10 @@ - (instancetype)initWithFrame:(CGRect)frame {
146146
}
147147

148148
- (instancetype)initWithTitle:(NSString *)scrollTitle
149-
scrollType:(TXScrollLabelViewType)scrollType
150-
scrollVelocity:(NSTimeInterval)scrollVelocity
151-
options:(UIViewAnimationOptions)options
152-
inset:(UIEdgeInsets)inset {
149+
type:(TXScrollLabelViewType)scrollType
150+
velocity:(NSTimeInterval)scrollVelocity
151+
options:(UIViewAnimationOptions)options
152+
inset:(UIEdgeInsets)inset {
153153
if (self = [super init]) {
154154
self.scrollTitle = scrollTitle;
155155
self.scrollType = scrollType;
@@ -160,51 +160,53 @@ - (instancetype)initWithTitle:(NSString *)scrollTitle
160160
return self;
161161
}
162162

163-
+ (instancetype)tx_setScrollTitle:(NSString *)scrollTitle {
163+
+ (instancetype)scrollWithTitle:(NSString *)scrollTitle {
164164

165-
return [self tx_setScrollTitle:scrollTitle
166-
scrollType:TXScrollLabelViewTypeLeftRight];
165+
return [self scrollWithTitle:scrollTitle
166+
type:TXScrollLabelViewTypeLeftRight];
167167
}
168168

169-
+ (instancetype)tx_setScrollTitle:(NSString *)scrollTitle
170-
scrollType:(TXScrollLabelViewType)scrollType {
169+
+ (instancetype)scrollWithTitle:(NSString *)scrollTitle
170+
type:(TXScrollLabelViewType)scrollType {
171171

172-
return [self tx_setScrollTitle:scrollTitle
173-
scrollType:scrollType
174-
scrollVelocity:TXScrollDefaultTimeInterval];
172+
return [self scrollWithTitle:scrollTitle
173+
type:scrollType
174+
velocity:TXScrollDefaultTimeInterval];
175175
}
176176

177-
+ (instancetype)tx_setScrollTitle:(NSString *)scrollTitle
178-
scrollType:(TXScrollLabelViewType)scrollType
179-
scrollVelocity:(NSTimeInterval)scrollVelocity {
177+
+ (instancetype)scrollWithTitle:(NSString *)scrollTitle
178+
type:(TXScrollLabelViewType)scrollType
179+
velocity:(NSTimeInterval)scrollVelocity {
180180

181-
return [self tx_setScrollTitle:scrollTitle
182-
scrollType:scrollType
183-
scrollVelocity:scrollVelocity
184-
options:UIViewAnimationOptionCurveEaseInOut];
181+
return [self scrollWithTitle:scrollTitle
182+
type:scrollType
183+
velocity:scrollVelocity
184+
options:UIViewAnimationOptionCurveEaseInOut];
185185
}
186186

187-
+ (instancetype)tx_setScrollTitle:(NSString *)scrollTitle
188-
scrollType:(TXScrollLabelViewType)scrollType
189-
scrollVelocity:(NSTimeInterval)scrollVelocity
190-
options:(UIViewAnimationOptions)options {
187+
+ (instancetype)scrollWithTitle:(NSString *)scrollTitle
188+
type:(TXScrollLabelViewType)scrollType
189+
velocity:(NSTimeInterval)scrollVelocity
190+
options:(UIViewAnimationOptions)options {
191191

192-
return [self tx_setScrollTitle:scrollTitle
193-
scrollType:scrollType
194-
scrollVelocity:scrollVelocity
195-
options:options inset:UIEdgeInsetsMake(0, 5, 0, 5)];
196-
}
197-
198-
+ (instancetype)tx_setScrollTitle:(NSString *)scrollTitle
199-
scrollType:(TXScrollLabelViewType)scrollType
200-
scrollVelocity:(NSTimeInterval)scrollVelocity
201-
options:(UIViewAnimationOptions)options
202-
inset:(UIEdgeInsets)inset {
192+
return [self scrollWithTitle:scrollTitle
193+
type:scrollType
194+
velocity:scrollVelocity
195+
options:options
196+
inset:UIEdgeInsetsMake(0, 5, 0, 5)];
197+
}
198+
199+
+ (instancetype)scrollWithTitle:(NSString *)scrollTitle
200+
type:(TXScrollLabelViewType)scrollType
201+
velocity:(NSTimeInterval)scrollVelocity
202+
options:(UIViewAnimationOptions)options
203+
inset:(UIEdgeInsets)inset {
203204

204205
return [[self alloc] initWithTitle:scrollTitle
205-
scrollType:scrollType
206-
scrollVelocity:scrollVelocity
207-
options:options inset:inset];
206+
type:scrollType
207+
velocity:scrollVelocity
208+
options:options
209+
inset:inset];
208210
}
209211

210212
#pragma mark - Getter & Setter Methods
@@ -511,3 +513,52 @@ - (void)dealloc {
511513
}
512514

513515
@end
516+
517+
@implementation TXScrollLabelView (TXScrollLabelViewDeprecated)
518+
519+
+ (instancetype)tx_setScrollTitle:(NSString *)scrollTitle {
520+
521+
return [self scrollWithTitle:scrollTitle];
522+
}
523+
524+
+ (instancetype)tx_setScrollTitle:(NSString *)scrollTitle
525+
scrollType:(TXScrollLabelViewType)scrollType {
526+
527+
return [self scrollWithTitle:scrollTitle
528+
type:scrollType];
529+
}
530+
531+
+ (instancetype)tx_setScrollTitle:(NSString *)scrollTitle
532+
scrollType:(TXScrollLabelViewType)scrollType
533+
scrollVelocity:(NSTimeInterval)scrollVelocity {
534+
535+
return [self scrollWithTitle:scrollTitle
536+
type:scrollType
537+
velocity:scrollVelocity];
538+
}
539+
540+
+ (instancetype)tx_setScrollTitle:(NSString *)scrollTitle
541+
scrollType:(TXScrollLabelViewType)scrollType
542+
scrollVelocity:(NSTimeInterval)scrollVelocity
543+
options:(UIViewAnimationOptions)options {
544+
545+
return [self scrollWithTitle:scrollTitle
546+
type:scrollType
547+
velocity:scrollVelocity
548+
options:options];
549+
}
550+
551+
+ (instancetype)tx_setScrollTitle:(NSString *)scrollTitle
552+
scrollType:(TXScrollLabelViewType)scrollType
553+
scrollVelocity:(NSTimeInterval)scrollVelocity
554+
options:(UIViewAnimationOptions)options
555+
inset:(UIEdgeInsets)inset {
556+
557+
return [self scrollWithTitle:scrollTitle
558+
type:scrollType
559+
velocity:scrollVelocity
560+
options:options
561+
inset:inset];
562+
}
563+
564+
@end

0 commit comments

Comments
 (0)