Commit 130fb692 cgx

基础框架搭建

1 个父辈 9f98abc7
正在显示 78 个修改的文件 包含 1538 行增加111 行删除
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="dDK-KA-sPQ">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--AI睡眠教练-->
<scene sceneID="mSr-VG-EoP">
<objects>
<viewController id="dDK-KA-sPQ" customClass="AISleepCoachController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="1eu-Nn-5E0">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<viewLayoutGuide key="safeArea" id="Pf1-fh-l6V"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
<tabBarItem key="tabBarItem" title="AI睡眠教练" image="aisleep" selectedImage="aisleep_selected" id="Il3-d5-iMT"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="8JB-OR-j2U" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2022" y="201"/>
</scene>
</scenes>
<resources>
<image name="aisleep" width="25" height="25"/>
<image name="aisleep_selected" width="25" height="25"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
//
// AISleepCoachController.h
// DreamSleep
//
// Created by peter on 2022/4/1.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface AISleepCoachController : UIViewController
@end
NS_ASSUME_NONNULL_END
//
// AISleepCoachController.m
// DreamSleep
//
// Created by peter on 2022/4/1.
//
#import "AISleepCoachController.h"
#import <WebKit/WebKit.h>
@interface AISleepCoachController () <WKNavigationDelegate>
@property (strong, nonatomic) WKWebView *aiWebView;
@property (nonatomic, strong) UIProgressView *progressView;
@end
@implementation AISleepCoachController
- (void)viewDidLoad {
[super viewDidLoad];
// 创建WKWebView对象,添加到界面(storyboard没有控件)
[self.view addSubview:self.aiWebView];
[self.view addSubview:self.progressView];
}
- (void)dealloc {
[self.aiWebView removeObserver:self forKeyPath:@"estimatedProgress"];
}
#pragma mark - WKWebView的监听方法
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
if ([keyPath isEqualToString:@"estimatedProgress"]) {
self.progressView.progress = self.aiWebView.estimatedProgress;
if (self.progressView.progress == 1) { self.progressView.hidden = YES; }
} else {
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}
#pragma mark - WKNavigationDelegate
// 开始加载
- (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
}
// 加载成功
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
}
// 加载失败
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
DSLog(@"百度主页加载失败:%@", error.userInfo);
}
- (WKWebView *)aiWebView {
if (!_aiWebView) {
_aiWebView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - kTabBarHeight)];
_aiWebView.backgroundColor = DSWhite;
[_aiWebView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:nil];
_aiWebView.navigationDelegate = self;
_aiWebView.scrollView.showsVerticalScrollIndicator = NO;
_aiWebView.scrollView.showsHorizontalScrollIndicator = NO;
NSURL *url = [NSURL URLWithString:@"https://www.pgyer.com/SMIb"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[_aiWebView loadRequest:request];
}
return _aiWebView;
}
- (UIProgressView *)progressView {
if (!_progressView) {
_progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 0)];
_progressView.tintColor = HighlightColor;
// 通过放大Y轴来改变高度
_progressView.transform = CGAffineTransformMakeScale(1.0f, 5.0f);;
}
return _progressView;
}
@end
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="sHr-aK-PhO">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--首页-->
<scene sceneID="EkL-aL-SLU">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="sHr-aK-PhO" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="首页" image="home" selectedImage="home_selected" id="KEK-X3-RY8"/>
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="rMp-Xs-yYU">
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="M3U-9a-TZh" kind="relationship" relationship="rootViewController" id="7Ny-Sf-Eck"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dv3-jw-tTl" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1609" y="-437"/>
</scene>
<!--Home View Controller-->
<scene sceneID="VE1-rv-Jri">
<objects>
<tableViewController id="M3U-9a-TZh" customClass="HomeViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" id="D8y-PB-6ar">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="0.96078431372549022" green="0.96862745098039216" blue="0.98039215686274506" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="homeCell" id="jVW-SR-dvw">
<rect key="frame" x="0.0" y="44.5" width="414" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="jVW-SR-dvw" id="Zml-vr-IKN">
<rect key="frame" x="0.0" y="0.0" width="414" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="M3U-9a-TZh" id="i3Q-1g-pDq"/>
<outlet property="delegate" destination="M3U-9a-TZh" id="Sf3-iK-5BY"/>
</connections>
</tableView>
<navigationItem key="navigationItem" id="PhF-qP-fG4"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="JUJ-0M-dod" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2390" y="-437"/>
</scene>
</scenes>
<resources>
<image name="home" width="25" height="25"/>
<image name="home_selected" width="25" height="25"/>
</resources>
</document>
// //
// SceneDelegate.h // HomeViewController.h
// DreamSleep // DreamSleep
// //
// Created by peter on 2022/3/29. // Created by peter on 2022/4/1.
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@interface SceneDelegate : UIResponder <UIWindowSceneDelegate> NS_ASSUME_NONNULL_BEGIN
@property (strong, nonatomic) UIWindow * window; @interface HomeViewController : UITableViewController
@end @end
NS_ASSUME_NONNULL_END
//
// HomeViewController.m
// DreamSleep
//
// Created by peter on 2022/4/1.
//
#import "HomeViewController.h"
@interface HomeViewController ()
@end
@implementation HomeViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
}
#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"homeCell" forIndexPath:indexPath];
return cell;
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina5_9" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="launcher.png" translatesAutoresizingMaskIntoConstraints="NO" id="uPj-2O-U8f">
<rect key="frame" x="0.0" y="44" width="375" height="734"/>
</imageView>
</subviews>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="uPj-2O-U8f" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="topMargin" id="C7n-w2-E52"/>
<constraint firstItem="uPj-2O-U8f" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" id="DZq-Ck-aEi"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="uPj-2O-U8f" secondAttribute="trailing" id="E3K-Ni-AMF"/>
<constraint firstItem="uPj-2O-U8f" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" id="kQ9-qg-hw4"/>
<constraint firstAttribute="bottomMargin" secondItem="uPj-2O-U8f" secondAttribute="bottom" id="sKP-pb-LPY"/>
<constraint firstItem="uPj-2O-U8f" firstAttribute="bottom" secondItem="6Tk-OE-BBY" secondAttribute="bottom" id="vpC-CM-itm"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
<resources>
<image name="launcher.png" width="147" height="90"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
//
// LauncherController.h
// DreamSleep
//
// Created by peter on 2022/4/1.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface LauncherController : UIViewController
@end
NS_ASSUME_NONNULL_END
//
// LauncherController.m
// DreamSleep
//
// Created by peter on 2022/4/1.
//
#import "LauncherController.h"
@interface LauncherController ()
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *topConstraints;
@end
@implementation LauncherController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = DSWhite;
self.topConstraints.constant = VLayout(320);
}
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="LauncherController">
<connections>
<outlet property="topConstraints" destination="MKe-Yc-9cR" id="vVg-jP-LHy"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="launcher" translatesAutoresizingMaskIntoConstraints="NO" id="jwZ-ms-XzV">
<rect key="frame" x="133.5" y="364" width="147" height="90"/>
<constraints>
<constraint firstAttribute="width" constant="147" id="I5v-gr-z9L"/>
<constraint firstAttribute="height" constant="90" id="W6O-ne-eBC"/>
</constraints>
</imageView>
</subviews>
<viewLayoutGuide key="safeArea" id="Q5M-cg-NOt"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="jwZ-ms-XzV" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="EYC-P8-bA7"/>
<constraint firstItem="jwZ-ms-XzV" firstAttribute="top" secondItem="Q5M-cg-NOt" secondAttribute="top" constant="320" id="MKe-Yc-9cR"/>
</constraints>
<point key="canvasLocation" x="139" y="62"/>
</view>
</objects>
<resources>
<image name="launcher" width="147" height="90"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
//
// LeadingController.h
// DreamSleep
//
// Created by peter on 2022/4/1.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface LeadingController : UIViewController
@end
NS_ASSUME_NONNULL_END
//
// LeadingController.m
// DreamSleep
//
// Created by peter on 2022/4/1.
//
#import "LeadingController.h"
@interface LeadingController ()
@end
@implementation LeadingController
- (void)viewDidLoad {
[super viewDidLoad];
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="LeadingController">
<connections>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<viewLayoutGuide key="safeArea" id="Q5M-cg-NOt"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<point key="canvasLocation" x="139" y="62"/>
</view>
</objects>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
...@@ -8,6 +8,6 @@ ...@@ -8,6 +8,6 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate> @interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow * window;
@end @end
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
// //
#import "AppDelegate.h" #import "AppDelegate.h"
#import "MacroFuncUtil.h" #import "LauncherController.h"
@interface AppDelegate () @interface AppDelegate ()
...@@ -15,23 +15,13 @@ ...@@ -15,23 +15,13 @@
@implementation AppDelegate @implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// self.window = [UIWindow.alloc initWithFrame:UIScreen.mainScreen.bounds];
DLog(@"ServerURL:%@", ServerURL); // self.window.backgroundColor = DSWhite;
// LauncherController *launchController = [[LauncherController alloc] init];
// self.window.rootViewController = launchController;
// [self.window makeKeyAndVisible];
return YES; return YES;
} }
#pragma mark - UISceneSession lifecycle
- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options API_AVAILABLE(ios(13.0)){
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
}
- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions API_AVAILABLE(ios(13.0)){
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
@end @end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="QZO-WX-k32">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="w5K-xW-e4g">
<rect key="frame" x="271" y="428" width="53" height="40"/>
<color key="backgroundColor" red="0.34509803919999998" green="0.33725490200000002" blue="0.83921568629999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="SuO-cK-DEA"/>
</constraints>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="跳转">
<color key="baseForegroundColor" red="1" green="0.58431372550000005" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</buttonConfiguration>
<connections>
<action selector="jumpAction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Gf5-hE-LM4"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3XS-aB-cOc">
<rect key="frame" x="104" y="428" width="53" height="40"/>
<color key="backgroundColor" red="0.34509803919999998" green="0.33725490200000002" blue="0.83921568629999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="1YM-Nd-x3U"/>
</constraints>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="切换">
<color key="baseForegroundColor" red="1" green="0.58431372550000005" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</buttonConfiguration>
<connections>
<action selector="changeAction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Gpe-Tg-5IV"/>
</connections>
</button>
</subviews>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="3XS-aB-cOc" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="89d-xm-J0M"/>
<constraint firstItem="w5K-xW-e4g" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="3XS-aB-cOc" secondAttribute="trailing" constant="8" symbolic="YES" id="F1s-Ia-UsP"/>
<constraint firstItem="w5K-xW-e4g" firstAttribute="height" secondItem="3XS-aB-cOc" secondAttribute="height" id="ON2-wH-o7f"/>
<constraint firstItem="w5K-xW-e4g" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="SV8-lj-wUp"/>
<constraint firstItem="3XS-aB-cOc" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="104" id="Xak-NY-5bK"/>
<constraint firstItem="w5K-xW-e4g" firstAttribute="width" secondItem="3XS-aB-cOc" secondAttribute="width" id="lqB-6m-ZnF"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="w5K-xW-e4g" secondAttribute="trailing" constant="90" id="o31-sb-lqQ"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="6054" y="582"/>
</scene>
<!--AI睡眠教练-->
<scene sceneID="mSr-VG-EoP">
<objects>
<viewController id="dDK-KA-sPQ" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="1eu-Nn-5E0">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<viewLayoutGuide key="safeArea" id="Pf1-fh-l6V"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
<tabBarItem key="tabBarItem" title="AI睡眠教练" image="aisleep" selectedImage="aisleep_selected" id="Il3-d5-iMT"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="8JB-OR-j2U" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2022" y="201"/>
</scene>
<!--View Controller-->
<scene sceneID="Gya-Tb-BFe">
<objects>
<viewController id="yNg-SU-x1g" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="RWL-Tf-26V">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<viewLayoutGuide key="safeArea" id="ras-Kd-lUv"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
<navigationItem key="navigationItem" id="xeT-zy-k3T"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="ehh-mg-56O" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2477" y="916"/>
</scene>
<!--Home View Controller-->
<scene sceneID="UFh-hR-hlH">
<objects>
<viewController id="Gfg-hN-ZF4" customClass="HomeViewController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Xj6-Mh-3lV">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<viewLayoutGuide key="safeArea" id="Nuf-wL-kdU"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
<navigationItem key="navigationItem" id="Mxm-1C-KOd"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="gz7-hU-NxS" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2374" y="-438"/>
</scene>
<!--Tab Bar Controller-->
<scene sceneID="ce9-hW-8Zi">
<objects>
<tabBarController id="QZO-WX-k32" sceneMemberID="viewController">
<tabBar key="tabBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="hwk-wY-PYO">
<rect key="frame" x="0.0" y="0.0" width="414" height="49"/>
<autoresizingMask key="autoresizingMask"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</tabBar>
<connections>
<segue destination="sHr-aK-PhO" kind="relationship" relationship="viewControllers" id="3hM-PG-ZQI"/>
<segue destination="dDK-KA-sPQ" kind="relationship" relationship="viewControllers" id="PLC-QQ-1fZ"/>
<segue destination="z46-F3-9B2" kind="relationship" relationship="viewControllers" id="3cF-1s-M4e"/>
</connections>
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="nyq-cf-tLQ" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="713" y="104"/>
</scene>
<!--首页-->
<scene sceneID="EkL-aL-SLU">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="sHr-aK-PhO" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="首页" image="home" selectedImage="home_selected" id="KEK-X3-RY8"/>
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="rMp-Xs-yYU">
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="Gfg-hN-ZF4" kind="relationship" relationship="rootViewController" id="YUM-gg-aXd"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dv3-jw-tTl" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1609" y="-437"/>
</scene>
<!--我的-->
<scene sceneID="XXm-nW-BLl">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="z46-F3-9B2" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="我的" image="profile" selectedImage="profile_selected" id="q0K-3e-nOn"/>
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="kJv-b2-G2C">
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="yNg-SU-x1g" kind="relationship" relationship="rootViewController" id="NtG-Ga-Dtr"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="G1r-vr-Uad" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1567" y="916"/>
</scene>
</scenes>
<resources>
<image name="aisleep" width="25" height="25"/>
<image name="aisleep_selected" width="25" height="25"/>
<image name="home" width="25" height="25"/>
<image name="home_selected" width="25" height="25"/>
<image name="profile" width="25" height="25"/>
<image name="profile_selected" width="25" height="25"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="QZO-WX-k32">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Tab Bar Controller-->
<scene sceneID="ce9-hW-8Zi">
<objects>
<tabBarController id="QZO-WX-k32" customClass="DSTabBarController" sceneMemberID="viewController">
<tabBar key="tabBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="hwk-wY-PYO">
<rect key="frame" x="0.0" y="0.0" width="414" height="49"/>
<autoresizingMask key="autoresizingMask"/>
</tabBar>
<connections>
<segue destination="c33-ux-a8E" kind="relationship" relationship="viewControllers" id="3hM-PG-ZQI"/>
<segue destination="Ldl-8e-8kZ" kind="relationship" relationship="viewControllers" id="PLC-QQ-1fZ"/>
<segue destination="mao-Qg-fTf" kind="relationship" relationship="viewControllers" id="3cF-1s-M4e"/>
</connections>
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="nyq-cf-tLQ" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="713" y="104"/>
</scene>
<!--Home-->
<scene sceneID="dDP-pO-M62">
<objects>
<viewControllerPlaceholder storyboardName="Home" id="c33-ux-a8E" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="首页" image="home" selectedImage="home_selected" id="Smw-jw-8ah"/>
</viewControllerPlaceholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="bce-l3-dq2" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1349" y="-213"/>
</scene>
<!--AISleepCoach-->
<scene sceneID="rVm-gi-KB1">
<objects>
<viewControllerPlaceholder storyboardName="AISleepCoach" id="Ldl-8e-8kZ" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="AI睡眠教练" image="aisleep" selectedImage="aisleep_selected" id="hhA-gt-gs3"/>
</viewControllerPlaceholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="h0L-Y4-DfH" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1386" y="104"/>
</scene>
<!--Profile-->
<scene sceneID="Q5J-Ct-RJu">
<objects>
<viewControllerPlaceholder storyboardName="Profile" id="mao-Qg-fTf" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="我的" image="profile" selectedImage="profile_selected" id="GRP-mg-DTk"/>
</viewControllerPlaceholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="SVV-y3-HSF" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1417" y="395"/>
</scene>
</scenes>
<resources>
<image name="aisleep" width="25" height="25"/>
<image name="aisleep_selected" width="25" height="25"/>
<image name="home" width="25" height="25"/>
<image name="home_selected" width="25" height="25"/>
<image name="profile" width="25" height="25"/>
<image name="profile_selected" width="25" height="25"/>
</resources>
</document>
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="z46-F3-9B2">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="Gya-Tb-BFe">
<objects>
<viewController id="yNg-SU-x1g" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="RWL-Tf-26V">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<viewLayoutGuide key="safeArea" id="ras-Kd-lUv"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
<navigationItem key="navigationItem" id="xeT-zy-k3T"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="ehh-mg-56O" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2477" y="916"/>
</scene>
<!--我的-->
<scene sceneID="XXm-nW-BLl">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="z46-F3-9B2" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="我的" image="profile" selectedImage="profile_selected" id="q0K-3e-nOn"/>
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="kJv-b2-G2C">
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="yNg-SU-x1g" kind="relationship" relationship="rootViewController" id="NtG-Ga-Dtr"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="G1r-vr-Uad" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1567" y="916"/>
</scene>
</scenes>
<resources>
<image name="profile" width="25" height="25"/>
<image name="profile_selected" width="25" height="25"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="QZO-WX-k32">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="w5K-xW-e4g">
<rect key="frame" x="271" y="428" width="53" height="40"/>
<color key="backgroundColor" red="0.34509803919999998" green="0.33725490200000002" blue="0.83921568629999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="SuO-cK-DEA"/>
</constraints>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="跳转">
<color key="baseForegroundColor" red="1" green="0.58431372550000005" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</buttonConfiguration>
<connections>
<action selector="jumpAction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Gf5-hE-LM4"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3XS-aB-cOc">
<rect key="frame" x="104" y="428" width="53" height="40"/>
<color key="backgroundColor" red="0.34509803919999998" green="0.33725490200000002" blue="0.83921568629999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="1YM-Nd-x3U"/>
</constraints>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="切换">
<color key="baseForegroundColor" red="1" green="0.58431372550000005" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</buttonConfiguration>
<connections>
<action selector="changeAction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Gpe-Tg-5IV"/>
</connections>
</button>
</subviews>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="3XS-aB-cOc" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="89d-xm-J0M"/>
<constraint firstItem="w5K-xW-e4g" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="3XS-aB-cOc" secondAttribute="trailing" constant="8" symbolic="YES" id="F1s-Ia-UsP"/>
<constraint firstItem="w5K-xW-e4g" firstAttribute="height" secondItem="3XS-aB-cOc" secondAttribute="height" id="ON2-wH-o7f"/>
<constraint firstItem="w5K-xW-e4g" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="SV8-lj-wUp"/>
<constraint firstItem="3XS-aB-cOc" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="104" id="Xak-NY-5bK"/>
<constraint firstItem="w5K-xW-e4g" firstAttribute="width" secondItem="3XS-aB-cOc" secondAttribute="width" id="lqB-6m-ZnF"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="w5K-xW-e4g" secondAttribute="trailing" constant="90" id="o31-sb-lqQ"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="6054" y="582"/>
</scene>
<!--View Controller-->
<scene sceneID="Gya-Tb-BFe">
<objects>
<viewController id="yNg-SU-x1g" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="RWL-Tf-26V">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<viewLayoutGuide key="safeArea" id="ras-Kd-lUv"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
<navigationItem key="navigationItem" id="xeT-zy-k3T"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="ehh-mg-56O" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2477" y="916"/>
</scene>
<!--Tab Bar Controller-->
<scene sceneID="ce9-hW-8Zi">
<objects>
<tabBarController id="QZO-WX-k32" sceneMemberID="viewController">
<tabBar key="tabBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="hwk-wY-PYO">
<rect key="frame" x="0.0" y="0.0" width="414" height="49"/>
<autoresizingMask key="autoresizingMask"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</tabBar>
<connections>
<segue destination="c33-ux-a8E" kind="relationship" relationship="viewControllers" id="3hM-PG-ZQI"/>
<segue destination="Ldl-8e-8kZ" kind="relationship" relationship="viewControllers" id="PLC-QQ-1fZ"/>
<segue destination="z46-F3-9B2" kind="relationship" relationship="viewControllers" id="3cF-1s-M4e"/>
</connections>
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="nyq-cf-tLQ" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="713" y="104"/>
</scene>
<!--我的-->
<scene sceneID="XXm-nW-BLl">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="z46-F3-9B2" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="我的" image="profile" selectedImage="profile_selected" id="q0K-3e-nOn"/>
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="kJv-b2-G2C">
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="yNg-SU-x1g" kind="relationship" relationship="rootViewController" id="NtG-Ga-Dtr"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="G1r-vr-Uad" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1567" y="916"/>
</scene>
<!--Home-->
<scene sceneID="dDP-pO-M62">
<objects>
<viewControllerPlaceholder storyboardName="Home" id="c33-ux-a8E" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="Item" id="Smw-jw-8ah"/>
</viewControllerPlaceholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="bce-l3-dq2" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1609" y="-437"/>
</scene>
<!--AISleepCoach-->
<scene sceneID="rVm-gi-KB1">
<objects>
<viewControllerPlaceholder storyboardName="AISleepCoach" id="Ldl-8e-8kZ" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="Item" id="hhA-gt-gs3"/>
</viewControllerPlaceholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="h0L-Y4-DfH" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2022" y="201"/>
</scene>
</scenes>
<resources>
<image name="profile" width="25" height="25"/>
<image name="profile_selected" width="25" height="25"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
//
// DSTabBarController.h
// DreamSleep
//
// Created by peter on 2022/4/1.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface DSTabBarController : UITabBarController
@end
NS_ASSUME_NONNULL_END
//
// DSTabBarController.m
// DreamSleep
//
// Created by peter on 2022/4/1.
//
#import "DSTabBarController.h"
@interface DSTabBarController ()
// 记录上一次点击tabbar
@property (nonatomic, assign) NSInteger indexFlag;
@end
@implementation DSTabBarController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// 设置tabbar背景色 && 隐藏tabbar分割线
self.tabBar.backgroundImage = [UIImage new];
self.tabBar.shadowImage = [UIImage new];
self.tabBar.dk_backgroundColorPicker = DKColorPickerWithKey(TabBarBG);
// 设置tabbar选中及未选中的文字颜色
self.tabBar.tintColor = ColorFromHex(0x62C3D5);
self.tabBar.unselectedItemTintColor = ColorFromHex(0x777777);
// 设置tabbaritem图片渲染模式
for (UITabBarItem *item in self.tabBar.items) {
item.image = [item.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
item.selectedImage = [item.selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
}
}
#pragma mark - UITabBarDelegate
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
NSInteger index = [self.tabBar.items indexOfObject:item];
if (index != self.indexFlag) {
// 执行动画
NSMutableArray *tmpArrays = [NSMutableArray array];
for (UIView *tabBarBtn in self.tabBar.subviews) {
if ([tabBarBtn isKindOfClass:NSClassFromString(@"UITabBarButton")]) {
[tmpArrays addObject:tabBarBtn];
}
}
// 添加动画
[self addScaleAnimtaionWithTabBarBtns:[tmpArrays copy] index:index];
self.indexFlag = index;
}
}
#pragma mark - 先放大,再缩小
- (void)addScaleAnimtaionWithTabBarBtns:(NSArray *)btns index:(NSInteger)index {
// 放大效果,并回到原位
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
// 速度控制函数,控制动画运行的节奏
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
// 执行时间
animation.duration = 0.2;
// 执行次数
animation.repeatCount = 1;
// 完成动画后会回到执行动画之前的状态
animation.autoreverses = YES;
// 初始伸缩倍数
animation.fromValue = [NSNumber numberWithFloat:0.9];
// 结束伸缩倍数
animation.toValue = [NSNumber numberWithFloat:1.1];
[[btns[index] layer] addAnimation:animation forKey:nil];
}
@end
//
// NetLoadingStateView.h
// DreamSleep
//
// Created by peter on 2022/4/4.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/// 网络加载状态view
@interface NetLoadingStateView : UIView
@end
NS_ASSUME_NONNULL_END
//
// NetLoadingStateView.m
// DreamSleep
//
// Created by peter on 2022/4/4.
//
#import "NetLoadingStateView.h"
@implementation NetLoadingStateView
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="z46-F3-9B2">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--我的-->
<scene sceneID="XXm-nW-BLl">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="z46-F3-9B2" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="我的" image="profile" selectedImage="profile_selected" id="q0K-3e-nOn"/>
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="kJv-b2-G2C">
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="yBJ-h0-v4i" kind="relationship" relationship="rootViewController" id="jqf-uo-1t8"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="G1r-vr-Uad" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1567" y="916"/>
</scene>
<!--Profile Controller-->
<scene sceneID="BCE-Q0-nsW">
<objects>
<tableViewController id="yBJ-h0-v4i" customClass="ProfileController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" id="cPA-gQ-sne">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="profileCell" id="Ngp-72-dyg">
<rect key="frame" x="0.0" y="44.5" width="414" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Ngp-72-dyg" id="oK7-pb-nmX">
<rect key="frame" x="0.0" y="0.0" width="414" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="yBJ-h0-v4i" id="TkL-Sb-y2M"/>
<outlet property="delegate" destination="yBJ-h0-v4i" id="hue-eL-5s2"/>
</connections>
</tableView>
<navigationItem key="navigationItem" id="SIx-Mw-05b"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="puR-y9-BaN" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2336" y="915"/>
</scene>
</scenes>
<resources>
<image name="profile" width="25" height="25"/>
<image name="profile_selected" width="25" height="25"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
//
// ProfileController.h
// DreamSleep
//
// Created by peter on 2022/4/1.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ProfileController : UITableViewController
@end
NS_ASSUME_NONNULL_END
//
// ProfileController.m
// DreamSleep
//
// Created by peter on 2022/4/1.
//
#import "ProfileController.h"
@interface ProfileController ()
@end
@implementation ProfileController
- (void)viewDidLoad {
[super viewDidLoad];
}
#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"profileCell" forIndexPath:indexPath];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// 模拟切换黑夜模式
if ([self.dk_manager.themeVersion isEqualToString:DKThemeVersionNight]) {
[self.dk_manager dawnComing];
} else {
[self.dk_manager nightFalling];
}
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
{
"images" : [
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "noti@2x.png",
"scale" : "2x"
},
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "noti@3x.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "setting@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "setting@3x.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "spotlight@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "spotlight@3x.png",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "appIcon@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "appIcon@3x.png",
"scale" : "3x"
},
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "appStoreIcon.png",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "aisleep.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "aisleep@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "aisleep@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "aisleep_selected.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "aisleep_selected@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "aisleep_selected@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "home.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "home@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "home@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "home_selected.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "home_selected@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "home_selected@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "profile.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "profile@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "profile@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "profile_selected.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "profile_selected@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "profile_selected@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
NORMAL NIGHT RED
#ffffff #343434 #fa3043 BG
#aaaaaa #313131 #aaaaaa SEP
#0000ff #ffffff #fa0000 TINT
#000000 #ffffff #000000 TEXT
#ffffff #444444 #ffffff BAR
#f0f0f0 #222222 #dedede HIGHLIGHTED
#FFFFFF #131724 #FAF5F5 TabBarBG
#F5F7FA #161E38 #FAF5F5 VCViewBG
//
// SceneDelegate.m
// DreamSleep
//
// Created by peter on 2022/3/29.
//
#import "SceneDelegate.h"
@interface SceneDelegate ()
@end
@implementation SceneDelegate
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions API_AVAILABLE(ios(13.0)){
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
}
- (void)sceneDidDisconnect:(UIScene *)scene API_AVAILABLE(ios(13.0)){
// Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded.
// Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
}
- (void)sceneDidBecomeActive:(UIScene *)scene API_AVAILABLE(ios(13.0)){
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}
- (void)sceneWillResignActive:(UIScene *)scene API_AVAILABLE(ios(13.0)){
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
}
- (void)sceneWillEnterForeground:(UIScene *)scene API_AVAILABLE(ios(13.0)){
// Called as the scene transitions from the background to the foreground.
// Use this method to undo the changes made on entering the background.
}
- (void)sceneDidEnterBackground:(UIScene *)scene API_AVAILABLE(ios(13.0)){
// Called as the scene transitions from the foreground to the background.
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.
}
@end
//
// TmpViewController.h
// DreamSleep
//
// Created by peter on 2022/3/30.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface TmpViewController : UIViewController
@end
NS_ASSUME_NONNULL_END
//
// TmpViewController.m
// DreamSleep
//
// Created by peter on 2022/3/30.
//
#import "TmpViewController.h"
@interface TmpViewController ()
@end
@implementation TmpViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
DSLog(@"11111");
}
@end
...@@ -5,22 +5,49 @@ ...@@ -5,22 +5,49 @@
// Created by peter on 2022/3/29. // Created by peter on 2022/3/29.
// //
#import <Foundation/Foundation.h> #import <UIKit/UIKit.h>
// 屏幕尺寸 // 屏幕尺寸
#define kScreenWidth [[UIScreen mainScreen] bounds].size.width #define kScreenWidth [[UIScreen mainScreen] bounds].size.width
#define kScreenHeight [[UIScreen mainScreen] bounds].size.height #define kScreenHeight [[UIScreen mainScreen] bounds].size.height
#define IPHONEHIGHT(b) [UIScreen mainScreen].bounds.size.height*((b)/812.0)
#define IPHONEWIDTH(a) [UIScreen mainScreen].bounds.size.width*((a)/375.0)
// 水平方向布局(iPhone X作为设计基准)
#define HLayout(H) kScreenWidth*(H/375.)
// 垂直方向布局
#define VLayout(V) kScreenHeight*(V/812.)
/** 标签栏高度 */
#define kTabBarHeight ([[UIApplication sharedApplication] statusBarFrame].size.height > 20 ? 83 : 49)
// UIColor // UIColor
#define UIColorFromRGB(R, G, B) [UIColor colorWithRed:((R) / 255.0f) green:((G) / 255.0f) blue:((B) / 255.0f) alpha:1.0f] #define ColorFromRGB(R, G, B) [UIColor colorWithRed:((R) / 255.0f) green:((G) / 255.0f) blue:((B) / 255.0f) alpha:1.0f]
#define UIColorFromRGBA(R, G, B, A) [UIColor colorWithRed:((R) / 255.0f) green:((G) / 255.0f) blue:((B) / 255.0f) alpha:A] #define ColorFromRGBA(R, G, B, A) [UIColor colorWithRed:((R) / 255.0f) green:((G) / 255.0f) blue:((B) / 255.0f) alpha:A]
#define UIColorFromHex(Hex) [UIColor colorWithRed:((Hex & 0xFF0000) >> 16)/255.0f green:((Hex & 0xFF00) >> 8)/255.0f blue:((Hex & 0xFF))/255.0f alpha:1.0f] #define ColorFromHex(Hex) [UIColor colorWithRed:((Hex & 0xFF0000) >> 16)/255.0f green:((Hex & 0xFF00) >> 8)/255.0f blue:((Hex & 0xFF))/255.0f alpha:1.0f]
#define UIColorFromHexA(Hex, A) [UIColor colorWithRed:((Hex & 0xFF0000) >> 16)/255.0f green:((Hex & 0xFF00) >> 8)/255.0f blue:((Hex & 0xFF))/255.0f alpha:A] #define ColorFromHexA(Hex, A) [UIColor colorWithRed:((Hex & 0xFF0000) >> 16)/255.0f green:((Hex & 0xFF00) >> 8)/255.0f blue:((Hex & 0xFF))/255.0f alpha:A]
NS_ASSUME_NONNULL_BEGIN /*
常用颜色值
*/
// 红色
#define DSRed [UIColor redColor]
// 白色
#define DSWhite [UIColor whiteColor]
@interface AdaptationUtil : NSObject /** 副文案颜色 */
#define SubTextColor [UIColor colorWithHexString:@"#A0A0A0"]
/** 输入说明文案颜色/白色背景列表分割线颜色 */
#define PlaceholderColor [UIColor colorWithHexString:@"#E6E6E6"]
/** 突出显示文案颜色 */
#define HighlightColor ColorFromHex(0x1AB69A)
/** 紧急提示文案颜色 */
#define UrgencyColor [UIColor colorWithHexString:@"#FD5E5E"]
NS_ASSUME_NONNULL_BEGIN
@interface AdaptationUtil : NSObject
// 获取keyWindow
+ (UIWindow *)getKeyWindow;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -9,4 +9,24 @@ ...@@ -9,4 +9,24 @@
@implementation AdaptationUtil @implementation AdaptationUtil
+ (UIWindow *)getKeyWindow {
if (@available(iOS 13.0,*)) {
NSArray *arr = [[[UIApplication sharedApplication] connectedScenes] allObjects];
UIWindowScene *windowScene = (UIWindowScene *)arr[0];
// 如果是普通APP开发,可以使用
// SceneDelegate *delegate = (SceneDelegate *)windowScene.delegate;
// UIWindow *mainWindow = delegate.window;
// 由于在sdk开发中,引入不了SceneDelegate的头文件,所以需要使用kvc获取宿主的app的window
UIWindow *mainWindow = [windowScene valueForKeyPath:@"delegate.window"];
if(mainWindow) {
return mainWindow;
} else {
return [UIApplication sharedApplication].windows.lastObject;
}
} else {
return [UIApplication sharedApplication].keyWindow;
}
}
@end @end
...@@ -7,19 +7,28 @@ ...@@ -7,19 +7,28 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
// 配置信息 // APP和KeyWindow
#define DSApplication [UIApplication sharedApplication]
#define DSKeyWindow [AdaptationUtil getKeyWindow]
// 系统及APP版本
#define DSSystemVersion ([[[UIDevice currentDevice] systemVersion] floatValue])
#define DSAppVersion ([[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"])
// Info配置信息
#define DSInfoDic [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"]] #define DSInfoDic [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"]]
// NSLog // weakSelf
#ifdef DEBUG #define WS(weakSelf) __weak __typeof(&*self)weakSelf = self;
# define DLog(fmt, ...) NSLog((@"[文件名:%s]\n" "[函数名:%s]\n" "[行号:%d] \n" fmt), __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__);
// Log打印
#if defined(DEBUG)
#define DSLog(format, ...) printf("\n[%s] %s [第%d行] %s\n", __TIME__, __FUNCTION__, __LINE__, [[NSString stringWithFormat:format, ## __VA_ARGS__] UTF8String]);
#else #else
# define DLog(...); #define DSLog(format, ...)
#endif #endif
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@interface MacroFuncUtil : NSObject @interface MacroFuncUtil : NSObject
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -12,4 +12,6 @@ ...@@ -12,4 +12,6 @@
#import "AdaptationUtil.h" #import "AdaptationUtil.h"
#import "MacroFuncUtil.h" #import "MacroFuncUtil.h"
#import <DKNightVersion/DKNightVersion.h>
#endif /* PrefixHeader_pch */ #endif /* PrefixHeader_pch */
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
// //
#import "ViewController.h" #import "ViewController.h"
#import <DKNightVersion/DKNightVersion.h>
#import "TmpViewController.h"
@interface ViewController () @interface ViewController ()
...@@ -16,6 +18,28 @@ ...@@ -16,6 +18,28 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(BG);
DSKeyWindow.backgroundColor = DSRed;
}
- (IBAction)changeAction:(id)sender {
if ([self.dk_manager.themeVersion isEqualToString:DKThemeVersionNight]) {
[self.dk_manager dawnComing];
} else if ([self.dk_manager.themeVersion isEqualToString:DKThemeVersionNormal]) {
self.dk_manager.themeVersion = @"RED";
} else {
[self.dk_manager nightFalling];
}
}
- (IBAction)jumpAction:(id)sender {
TmpViewController *vc = [TmpViewController new];
vc.view.dk_backgroundColorPicker = DKColorPickerWithKey(BG);
[self presentViewController:vc animated:YES completion:nil];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
DSLog(@"2222");
} }
@end @end
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!