Skip to content

Commit

Permalink
Merge pull request #272 from Zohar163/master
Browse files Browse the repository at this point in the history
增加一个轮播文字对齐方式
  • Loading branch information
gsdios authored Feb 19, 2017
2 parents 1d66ce3 + 2a3c18c commit 0114dde
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
@property (nonatomic, strong) UIFont *titleLabelTextFont;
@property (nonatomic, strong) UIColor *titleLabelBackgroundColor;
@property (nonatomic, assign) CGFloat titleLabelHeight;
@property (nonatomic, assign) NSTextAlignment titleLabelTextAlignment;

@property (nonatomic, assign) BOOL hasConfigured;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ - (void)setTitle:(NSString *)title
}
}

-(void)setTitleLabelTextAlignment:(NSTextAlignment)titleLabelTextAlignment
{
_titleLabelTextAlignment = titleLabelTextAlignment;
_titleLabel.textAlignment = titleLabelTextAlignment;
}

- (void)layoutSubviews
{
Expand Down
2 changes: 2 additions & 0 deletions SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ typedef enum {
/** 轮播文字label高度 */
@property (nonatomic, assign) CGFloat titleLabelHeight;

/** 轮播文字label对齐方式 */
@property (nonatomic, assign) NSTextAlignment titleLabelTextAlignment;


////////////////////// 清除缓存接口 //////////////////////
Expand Down
2 changes: 2 additions & 0 deletions SDCycleScrollView/Lib/SDCycleScrollView/SDCycleScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ - (void)initialization
_titleLabelTextFont= [UIFont systemFontOfSize:14];
_titleLabelBackgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
_titleLabelHeight = 30;
_titleLabelTextAlignment = NSTextAlignmentLeft;
_autoScroll = YES;
_infiniteLoop = YES;
_showPageControl = YES;
Expand Down Expand Up @@ -566,6 +567,7 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell
if (!cell.hasConfigured) {
cell.titleLabelBackgroundColor = self.titleLabelBackgroundColor;
cell.titleLabelHeight = self.titleLabelHeight;
cell.titleLabelTextAlignment = self.titleLabelTextAlignment;
cell.titleLabelTextColor = self.titleLabelTextColor;
cell.titleLabelTextFont = self.titleLabelTextFont;
cell.hasConfigured = YES;
Expand Down

0 comments on commit 0114dde

Please sign in to comment.