Skip to content

Commit deaec43

Browse files
author
乐升平
committed
适配深色模式
1 parent 960f832 commit deaec43

22 files changed

Lines changed: 488 additions & 145 deletions

File tree

Example/.DS_Store

0 Bytes
Binary file not shown.

Example/SPAlertController.xcodeproj/project.pbxproj

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
52F6A5C321B60F86006AF8CC /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 52F6A5C121B60F86006AF8CC /* LaunchScreen.storyboard */; };
5050
52F6A5D021B60F86006AF8CC /* SPAlertControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 52F6A5CF21B60F86006AF8CC /* SPAlertControllerTests.m */; };
5151
52F6A5DB21B60F86006AF8CC /* SPAlertControllerUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 52F6A5DA21B60F86006AF8CC /* SPAlertControllerUITests.m */; };
52+
BB05FF082455887700950629 /* UIColor+DarkMode.m in Sources */ = {isa = PBXBuildFile; fileRef = BB05FF072455887700950629 /* UIColor+DarkMode.m */; };
5253
/* End PBXBuildFile section */
5354

5455
/* Begin PBXContainerItemProxy section */
@@ -132,6 +133,8 @@
132133
52F6A5DC21B60F86006AF8CC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
133134
52F6A5E921B6101D006AF8CC /* SPAlertController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPAlertController.m; sourceTree = "<group>"; };
134135
52F6A5EA21B6101D006AF8CC /* SPAlertController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPAlertController.h; sourceTree = "<group>"; };
136+
BB05FF062455887700950629 /* UIColor+DarkMode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIColor+DarkMode.h"; sourceTree = "<group>"; };
137+
BB05FF072455887700950629 /* UIColor+DarkMode.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIColor+DarkMode.m"; sourceTree = "<group>"; };
135138
/* End PBXFileReference section */
136139

137140
/* Begin PBXFrameworksBuildPhase section */
@@ -311,6 +314,8 @@
311314
52F6A5B721B60F83006AF8CC /* AppDelegate.m */,
312315
52F6A5B921B60F83006AF8CC /* ViewController.h */,
313316
52F6A5BA21B60F83006AF8CC /* ViewController.m */,
317+
BB05FF062455887700950629 /* UIColor+DarkMode.h */,
318+
BB05FF072455887700950629 /* UIColor+DarkMode.m */,
314319
52CB4AB021B616E400B6090B /* CustomViews */,
315320
52F6A5BC21B60F83006AF8CC /* Main.storyboard */,
316321
52F6A5BF21B60F86006AF8CC /* Assets.xcassets */,
@@ -506,6 +511,7 @@
506511
522C267D21D0D5B2004EBDEB /* SendAlertView.m in Sources */,
507512
52CB4AD321B616E400B6090B /* PassWordView.m in Sources */,
508513
090BCB9921CEAE2200057E1F /* SPButton.m in Sources */,
514+
BB05FF082455887700950629 /* UIColor+DarkMode.m in Sources */,
509515
52CB4ACC21B616E400B6090B /* MyCenterView.m in Sources */,
510516
522C267321D0C422004EBDEB /* ScoreView.m in Sources */,
511517
522C267021D0C31F004EBDEB /* HCSStarRatingView.m in Sources */,
@@ -687,7 +693,7 @@
687693
buildSettings = {
688694
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
689695
CODE_SIGN_STYLE = Automatic;
690-
DEVELOPMENT_TEAM = N7GTHGMGVY;
696+
DEVELOPMENT_TEAM = AYQTA2673R;
691697
INFOPLIST_FILE = SPAlertController/Info.plist;
692698
LD_RUNPATH_SEARCH_PATHS = (
693699
"$(inherited)",
@@ -704,7 +710,7 @@
704710
buildSettings = {
705711
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
706712
CODE_SIGN_STYLE = Automatic;
707-
DEVELOPMENT_TEAM = N7GTHGMGVY;
713+
DEVELOPMENT_TEAM = AYQTA2673R;
708714
INFOPLIST_FILE = SPAlertController/Info.plist;
709715
LD_RUNPATH_SEARCH_PATHS = (
710716
"$(inherited)",
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Bucket
3+
uuid = "A3CD0402-F63C-42F8-87D1-333854AEA9C9"
4+
type = "1"
5+
version = "2.0">
6+
</Bucket>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>SchemeUserState</key>
6+
<dict>
7+
<key>SPAlertController.xcscheme_^#shared#^_</key>
8+
<dict>
9+
<key>orderHint</key>
10+
<integer>0</integer>
11+
</dict>
12+
</dict>
13+
</dict>
14+
</plist>

Example/SPAlertController/CustomViews/CustomView1/SendAlertView.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#import "SendAlertView.h"
1010
#import "SPTextView.h"
11+
#import "UIColor+DarkMode.h"
12+
1113
@interface SendAlertView() <UITextViewDelegate>
1214
@property (weak, nonatomic) IBOutlet UIImageView *userIconView;
1315
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@@ -27,6 +29,7 @@ + (instancetype)shareSendAlertView {
2729

2830
- (void)awakeFromNib {
2931
[super awakeFromNib];
32+
self.backgroundColor = [UIColor colorPairsWithLightColor:[UIColor whiteColor] darkColor:[UIColor colorWithRed:44.0 / 255.0 green:44.0 / 255.0 blue:44.0 / 255.0 alpha:1.0]];
3033
self.userIconView.layer.cornerRadius = 4.0;
3134
self.userIconView.layer.masksToBounds = YES;
3235
self.textView.delegate = self;

Example/SPAlertController/CustomViews/CustomView1/SendAlertView.xib

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
3-
<device id="retina4_7" orientation="portrait">
4-
<adaptation id="fullscreen"/>
5-
</device>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
3+
<device id="retina4_7" orientation="portrait" appearance="light"/>
64
<dependencies>
75
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
97
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
108
</dependencies>
119
<objects>
@@ -90,7 +88,7 @@
9088
<outlet property="textViewHeightConstraint" destination="YHY-P9-chA" id="Fgo-3U-LEO"/>
9189
<outlet property="userIconView" destination="86f-jd-EJK" id="dw1-hK-pXo"/>
9290
</connections>
93-
<point key="canvasLocation" x="-470" y="81"/>
91+
<point key="canvasLocation" x="-471.19999999999999" y="80.50974512743629"/>
9492
</view>
9593
</objects>
9694
<resources>

Example/SPAlertController/CustomViews/CustomView17/ScoreView.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#import "ScoreView.h"
1010
#import "HCSStarRatingView.h"
11+
#import "UIColor+DarkMode.h"
1112

1213
@interface ScoreView()
1314

@@ -22,6 +23,8 @@ @implementation ScoreView
2223
- (instancetype)initWithFrame:(CGRect)frame {
2324
if (self = [super initWithFrame:frame]) {
2425

26+
self.backgroundColor = [UIColor alertBackgroundColor];
27+
2528
HCSStarRatingView *starRatingView = [[HCSStarRatingView alloc] init];
2629
starRatingView.translatesAutoresizingMaskIntoConstraints = NO;
2730
starRatingView.maximumValue = 5;
@@ -30,6 +33,7 @@ - (instancetype)initWithFrame:(CGRect)frame {
3033
starRatingView.spacing = 20;
3134
starRatingView.tintColor = [UIColor colorWithRed:0.0 green:0.48 blue:1.0 alpha:1.0];
3235
starRatingView.allowsHalfStars = YES;
36+
starRatingView.backgroundColor = [UIColor alertBackgroundColor];
3337
[starRatingView addTarget:self action:@selector(starRatingViewDidChangeValue:) forControlEvents:UIControlEventValueChanged];
3438
[self addSubview:starRatingView];
3539
_starRatingView = starRatingView;
@@ -42,7 +46,7 @@ - (instancetype)initWithFrame:(CGRect)frame {
4246

4347
UIButton *finishButton = [UIButton buttonWithType:UIButtonTypeCustom];
4448
finishButton.translatesAutoresizingMaskIntoConstraints = NO;
45-
finishButton.backgroundColor = [UIColor whiteColor];
49+
finishButton.backgroundColor = [UIColor alertBackgroundColor];
4650
[finishButton setTitle:@"完成" forState:UIControlStateNormal];
4751
[finishButton setTitleColor:[UIColor colorWithRed:0.0 green:0.48 blue:1.0 alpha:1.0] forState:UIControlStateNormal];
4852
[finishButton addTarget:self action:@selector(finishButtonAction) forControlEvents:UIControlEventTouchUpInside];

Example/SPAlertController/CustomViews/CustomView2/MyView.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
#import "MyView.h"
10+
#import "UIColor+DarkMode.h"
1011

1112
@interface MyView()
1213

@@ -22,6 +23,10 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder {
2223

2324
- (void)awakeFromNib {
2425
[super awakeFromNib];
26+
27+
self.backgroundColor = [UIColor colorPairsWithLightColor:[UIColor whiteColor] darkColor:[UIColor blackColor]];
28+
29+
self.passwordView.pointColor = [UIColor colorPairsWithLightColor:[UIColor blackColor] darkColor:[UIColor whiteColor]];
2530
}
2631

2732

Example/SPAlertController/CustomViews/CustomView2/MyView.xib

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
3-
<device id="retina4_7" orientation="portrait">
4-
<adaptation id="fullscreen"/>
5-
</device>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
3+
<device id="retina4_7" orientation="portrait" appearance="light"/>
64
<dependencies>
75
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
97
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
108
</dependencies>
119
<objects>
@@ -54,15 +52,6 @@
5452
<nil key="textColor"/>
5553
<nil key="highlightedColor"/>
5654
</label>
57-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="249" text="8毛钱" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eaD-jF-Fio">
58-
<rect key="frame" x="98" y="40" width="79" height="43.5"/>
59-
<constraints>
60-
<constraint firstAttribute="height" priority="999" constant="50" id="rXQ-BL-pYK"/>
61-
</constraints>
62-
<fontDescription key="fontDescription" type="system" pointSize="30"/>
63-
<nil key="textColor"/>
64-
<nil key="highlightedColor"/>
65-
</label>
6655
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jLf-TD-uIN">
6756
<rect key="frame" x="15" y="88.5" width="245" height="0.5"/>
6857
<color key="backgroundColor" red="0.14901960780000001" green="0.69803921570000005" blue="0.15686274510000001" alpha="1" colorSpace="calibratedRGB"/>
@@ -86,6 +75,15 @@
8675
<constraint firstAttribute="height" constant="0.5" id="vWc-qT-iyb"/>
8776
</constraints>
8877
</view>
78+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="249" misplaced="YES" text="8毛钱" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eaD-jF-Fio">
79+
<rect key="frame" x="98" y="37" width="79" height="43.5"/>
80+
<constraints>
81+
<constraint firstAttribute="height" priority="999" constant="50" id="rXQ-BL-pYK"/>
82+
</constraints>
83+
<fontDescription key="fontDescription" type="system" pointSize="30"/>
84+
<nil key="textColor"/>
85+
<nil key="highlightedColor"/>
86+
</label>
8987
</subviews>
9088
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
9189
<constraints>
@@ -154,6 +152,6 @@
154152
</view>
155153
</objects>
156154
<resources>
157-
<image name="取消" width="50" height="50"/>
155+
<image name="取消" width="25" height="25"/>
158156
</resources>
159157
</document>

0 commit comments

Comments
 (0)