Public The UILabel array of FSCalendarWeekdayView
This commit is contained in:
parent
08aa20df42
commit
3eccc3ad7d
|
|
@ -67,6 +67,12 @@
|
|||
|
||||
@end
|
||||
|
||||
@interface FSCalendarWeekdayView (Dynamic)
|
||||
|
||||
@property (readwrite, nonatomic) FSCalendar *calendar;
|
||||
|
||||
@end
|
||||
|
||||
@interface FSCalendarDelegationProxy()<FSCalendarDataSource,FSCalendarDelegate,FSCalendarDelegateAppearance>
|
||||
@end
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@interface FSCalendarWeekdayView : UIView
|
||||
|
||||
@property (weak, nonatomic) FSCalendar *calendar;
|
||||
/**
|
||||
An array of UILabel objects displaying the weekday symbols.
|
||||
*/
|
||||
@property (readonly, nonatomic) NSArray<UILabel *> *weekdayLabels;
|
||||
|
||||
- (void)configureAppearance;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,8 +13,9 @@
|
|||
|
||||
@interface FSCalendarWeekdayView()
|
||||
|
||||
@property (strong, nonatomic) NSPointerArray *weekdayLabels;
|
||||
@property (strong, nonatomic) NSPointerArray *weekdayPointers;
|
||||
@property (weak , nonatomic) UIView *contentView;
|
||||
@property (weak , nonatomic) FSCalendar *calendar;
|
||||
|
||||
- (void)commonInit;
|
||||
|
||||
|
|
@ -46,12 +47,12 @@
|
|||
[self addSubview:contentView];
|
||||
_contentView = contentView;
|
||||
|
||||
_weekdayLabels = [NSPointerArray weakObjectsPointerArray];
|
||||
_weekdayPointers = [NSPointerArray weakObjectsPointerArray];
|
||||
for (int i = 0; i < 7; i++) {
|
||||
UILabel *weekdayLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
weekdayLabel.textAlignment = NSTextAlignmentCenter;
|
||||
[self.contentView addSubview:weekdayLabel];
|
||||
[_weekdayLabels addPointer:(__bridge void * _Nullable)(weekdayLabel)];
|
||||
[_weekdayPointers addPointer:(__bridge void * _Nullable)(weekdayLabel)];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -62,7 +63,7 @@
|
|||
self.contentView.frame = self.bounds;
|
||||
|
||||
CGFloat weekdayWidth = self.fs_width/self.weekdayLabels.count;
|
||||
[self.weekdayLabels.allObjects enumerateObjectsUsingBlock:^(UILabel *weekdayLabel, NSUInteger index, BOOL *stop) {
|
||||
[self.weekdayLabels enumerateObjectsUsingBlock:^(UILabel *weekdayLabel, NSUInteger index, BOOL *stop) {
|
||||
weekdayLabel.frame = CGRectMake(index*weekdayWidth, 0, weekdayWidth, self.contentView.fs_height);
|
||||
}];
|
||||
|
||||
|
|
@ -89,11 +90,11 @@
|
|||
};
|
||||
|
||||
#if TARGET_INTERFACE_BUILDER
|
||||
[self.weekdayLabels.allObjects enumerateObjectsUsingBlock:^(UILabel * _Nonnull label, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
[self.weekdayLabels enumerateObjectsUsingBlock:^(UILabel * _Nonnull label, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
configureLabel(label,idx);
|
||||
}];
|
||||
#else
|
||||
[self.weekdayLabels.allObjects enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(UILabel * _Nonnull label, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
[self.weekdayLabels enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(UILabel * _Nonnull label, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
if ([NSThread isMainThread]) {
|
||||
configureLabel(label,idx);
|
||||
} else {
|
||||
|
|
@ -104,7 +105,8 @@
|
|||
}];
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
- (NSArray<UILabel *> *)weekdayLabels { return self.weekdayPointers.allObjects; }
|
||||
|
||||
@end
|
||||
|
|
|
|||
Loading…
Reference in New Issue