Skip to content

Commit b338ee5

Browse files
committed
继续优化自己封装的轮播图View---TTCycleScrollView
继续优化自己封装的轮播图View---TTCycleScrollView
1 parent 8568fec commit b338ee5

5 files changed

Lines changed: 24 additions & 16 deletions

File tree

Binary file not shown.

‎TTNews/Classes/News/Controller/ContentTableViewController.m‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,13 @@ @interface ContentTableViewController ()<TTCycleScrollViewDelegate>
3030
@property (nonatomic, assign) NSInteger currentPage;
3131
@property (nonatomic, strong) NSMutableArray *normalNewsArray;
3232
@property (nonatomic, weak) TTCycleScrollView *headerView;
33-
@property (nonatomic, weak) UILabel *headerLabel;
34-
@property (nonatomic, weak) UIPageControl *pageControl;
35-
@property (nonatomic, strong) NSTimer *timer;
36-
@property (nonatomic, weak) UIImageView *leftImageView;
37-
@property (nonatomic, weak) UIImageView *middleImageView;
38-
@property (nonatomic, weak) UIImageView *rightImageView;
3933
@property (nonatomic, copy) NSString *currentSkinModel;
4034

4135
@end
4236

4337
static NSString * const singlePictureCell = @"SinglePictureCell";
4438
static NSString * const multiPictureCell = @"MultiPictureCell";
4539
static NSString * const noPictureCell = @"NoPictureCell";
46-
static NSString * const apikey = @"8b72ce2839d6eea0869b4c2c60d2a449";
4740

4841
@implementation ContentTableViewController
4942

@@ -70,11 +63,12 @@ -(void)viewWillDisappear:(BOOL)animated {
7063

7164
-(void)updateSkinModel {
7265
self.currentSkinModel = [[NSUserDefaults standardUserDefaults] stringForKey:CurrentSkinModelKey];
73-
if ([self.currentSkinModel isEqualToString:NightSkinModelValue]) { self.tableView.backgroundColor = [UIColor blackColor];
74-
self.headerLabel.textColor = [UIColor lightGrayColor];
66+
if ([self.currentSkinModel isEqualToString:NightSkinModelValue]) {//夜间模式
67+
self.tableView.backgroundColor = [UIColor blackColor];
68+
[self.headerView updateToNightSkinMode];
7569
} else {//日间模式
7670
self.tableView.backgroundColor = [UIColor colorWithRed:250.0/255.0 green:250.0/255.0 blue:250.0/255.0 alpha:1.0];
77-
self.headerLabel.textColor = [UIColor whiteColor];
71+
[self.headerView updateToDaySkinMode];
7872
}
7973
[self.tableView reloadData];
8074
}

‎TTNews/Classes/News/View/TTCycleScrollView.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,8 @@
2727
- (void)updateImageViewsAndTitleLabel;
2828
- (void)addTimer;
2929
- (void)removeTimer;
30+
-(void)updateToDaySkinMode;
31+
-(void)updateToNightSkinMode;
32+
3033

3134
@end

‎TTNews/Classes/News/View/TTCycleScrollView.m‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ @interface TTCycleScrollView ()<UIScrollViewDelegate>
1717
@property (nonatomic, weak) UIImageView *rightImageView;
1818
@property (nonatomic, weak) UIView *bottomContianerView;
1919
@property (nonatomic, weak) UIPageControl *pageControl;
20-
@property (nonatomic, weak) UILabel *titleLabel;
2120
@property (nonatomic, strong) NSTimer *timer;
21+
@property (nonatomic, weak) UILabel *titleLabel;
2222

2323
@end
2424

@@ -79,7 +79,6 @@ - (void)initialization {
7979
CGFloat kPageControlWidth = [pageControl sizeForNumberOfPages:5].width;
8080
CGFloat margin = 10;
8181
pageControl.frame = CGRectMake(bottomContianerView.frame.size.width - kPageControlWidth - margin, 0, kPageControlWidth, bottomContianerView.frame.size.height);
82-
pageControl.currentPageIndicatorTintColor = [UIColor colorWithRed:243/255.0 green:75/255.0 blue:80/255.0 alpha:1.0];
8382

8483
[bottomContianerView addSubview:pageControl];
8584

@@ -167,4 +166,16 @@ - (void)clickMiddleImageView {
167166
}
168167
}
169168

169+
#pragma mark 切换至日间模式
170+
-(void)updateToDaySkinMode {
171+
self.pageControl.currentPageIndicatorTintColor = [UIColor colorWithRed:243/255.0 green:75/255.0 blue:80/255.0 alpha:1.0];
172+
self.titleLabel.textColor = [UIColor whiteColor];
173+
}
174+
175+
#pragma mark 切换至夜间模式
176+
-(void)updateToNightSkinMode {
177+
self.pageControl.currentPageIndicatorTintColor = [UIColor blackColor];
178+
self.titleLabel.textColor = [UIColor lightGrayColor];
179+
}
180+
170181
@end

‎TTNews/LaunchScreen.xib‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
3131
<nil key="highlightedColor"/>
3232
</label>
33-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Trending News Everyday" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Lbp-PU-6nq">
34-
<rect key="frame" x="206" y="370" width="189" height="21"/>
33+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Trending News Everyday" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Lbp-PU-6nq">
34+
<rect key="frame" x="202" y="370" width="197.5" height="21"/>
3535
<fontDescription key="fontDescription" type="system" pointSize="17"/>
3636
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
3737
<nil key="highlightedColor"/>
3838
</label>
39-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="💕Made with love by YangJunhui" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4gj-Tz-lCe">
40-
<rect key="frame" x="174" y="559.5" width="253" height="20.5"/>
39+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="💕 Made with love by YangJunhui" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4gj-Tz-lCe">
40+
<rect key="frame" x="172" y="559" width="257.5" height="20.5"/>
4141
<fontDescription key="fontDescription" type="system" pointSize="17"/>
4242
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
4343
<nil key="highlightedColor"/>

0 commit comments

Comments
 (0)