├── .DS_Store ├── .gitignore ├── README.md ├── YYButton ├── .DS_Store ├── YYButton.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── YYButton │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ ├── ViewController.swift │ └── hightImage.png ├── YYButtonTests │ ├── Info.plist │ └── YYButtonTests.swift ├── YYButtonUITests │ ├── Info.plist │ └── YYButtonUITests.swift └── 屏幕快照 2018-06-27 上午11.05.24.png ├── YYCollectionView ├── .DS_Store ├── YYCollectionView.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── YYCollectionView │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── CollectionFootView.swift │ ├── CollectionHeaderView.swift │ ├── CollectionViewCell.swift │ ├── CollectionViewCell.xib │ ├── Info.plist │ └── ViewController.swift ├── YYCollectionViewTests │ ├── Info.plist │ └── YYCollectionViewTests.swift ├── YYCollectionViewUITests │ ├── Info.plist │ └── YYCollectionViewUITests.swift └── 屏幕快照 2018-06-27 下午4.44.50.png ├── YYLabel ├── .DS_Store ├── Label.png ├── YYLabel.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── YYLabel │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ └── ViewController.swift ├── YYLabelTests │ ├── Info.plist │ └── YYLabelTests.swift └── YYLabelUITests │ ├── Info.plist │ └── YYLabelUITests.swift ├── YYTableView ├── .DS_Store ├── YYTableView.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── YYTableView │ ├── .DS_Store │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ ├── .DS_Store │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Contents.json │ │ └── image.imageset │ │ │ ├── Contents.json │ │ │ └── 经典@2x.png │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── CustomCellController.swift │ ├── CustomTableViewCell.swift │ ├── Info.plist │ ├── NibCellController.swift │ ├── NibTableViewCell.swift │ ├── NibTableViewCell.xib │ └── ViewController.swift ├── YYTableViewTests │ ├── Info.plist │ └── YYTableViewTests.swift ├── YYTableViewUITests │ ├── Info.plist │ └── YYTableViewUITests.swift └── 屏幕快照 2018-06-27 下午2.14.27.png ├── YYTextField ├── .DS_Store ├── TextField.png ├── YYTextField.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── YYTextField │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ ├── ViewController.swift │ └── testImage.png ├── YYTextFieldTests │ ├── Info.plist │ └── YYTextFieldTests.swift └── YYTextFieldUITests │ ├── Info.plist │ └── YYTextFieldUITests.swift ├── YYUITextView ├── .DS_Store ├── YYUITextView.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── YYUITextView │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ └── ViewController.swift ├── YYUITextViewTests │ ├── Info.plist │ └── YYUITextViewTests.swift ├── YYUITextViewUITests │ ├── Info.plist │ └── YYUITextViewUITests.swift └── 屏幕快照 2018-06-27 上午10.48.02.png └── YYWKWebView ├── .DS_Store ├── YYWKWebView.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── YYWKWebView ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist └── ViewController.swift ├── YYWKWebViewTests ├── Info.plist └── YYWKWebViewTests.swift └── YYWKWebViewUITests ├── Info.plist └── YYWKWebViewUITests.swift /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daomoer/YYSwiftLearnDemos/1fc858e6dbb0949b91fb17d7c8fecfaaadb8c7a6/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | # Package.resolved 41 | .build/ 42 | 43 | # CocoaPods 44 | # 45 | # We recommend against adding the Pods directory to your .gitignore. However 46 | # you should judge for yourself, the pros and cons are mentioned at: 47 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 48 | # 49 | # Pods/ 50 | 51 | # Carthage 52 | # 53 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 54 | # Carthage/Checkouts 55 | 56 | Carthage/Build 57 | 58 | # fastlane 59 | # 60 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 61 | # screenshots whenever they are needed. 62 | # For more information about the recommended setup visit: 63 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 64 | 65 | fastlane/report.xml 66 | fastlane/Preview.html 67 | fastlane/screenshots/**/*.png 68 | fastlane/test_output 69 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # YYSwiftLearnDemos 2 | 回顾swift学习 3 | 1.swift4.2 UILabel基本用法效果图 4 | ![image](https://github.com/daomoer/YYSwiftLearnDemos/blob/master/YYLabel/Label.png) 5 | 6 | 2.swift4.2 UIButton基本用法效果图 7 | ![image](https://github.com/daomoer/YYSwiftLearnDemos/blob/master/YYButton/屏幕快照%202018-06-27%20上午11.05.24.png) 8 | 9 | 3.swift4.2 UITextField基本用法效果图 10 | ![image](https://github.com/daomoer/YYSwiftLearnDemos/blob/master/YYTextField/TextField.png) 11 | 12 | 4.swift4.2 UITextView基本用法效果图 13 | ![image](https://github.com/daomoer/YYSwiftLearnDemos/blob/master/YYUITextView/屏幕快照%202018-06-27%20上午10.48.02.png) 14 | 15 | 5.swift4.2 UITableView基本用法效果图 16 | ![image](https://github.com/daomoer/YYSwiftLearnDemos/blob/master/YYTableView/屏幕快照%202018-06-27%20下午2.14.27.png) 17 | 18 | 6.swift4.2 UICollection基本用法效果图 19 | ![image](https://github.com/daomoer/YYSwiftLearnDemos/blob/master/YYCollectionView/屏幕快照%202018-06-27%20下午4.44.50.png) 20 | 21 | -------------------------------------------------------------------------------- /YYButton/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daomoer/YYSwiftLearnDemos/1fc858e6dbb0949b91fb17d7c8fecfaaadb8c7a6/YYButton/.DS_Store -------------------------------------------------------------------------------- /YYButton/YYButton.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /YYButton/YYButton/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // YYButton 4 | // 5 | // Created by Domo on 2018/6/26. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | 19 | let rootVC = ViewController() 20 | let rootNav = UINavigationController.init(rootViewController: rootVC) 21 | window?.rootViewController = rootNav 22 | window?.makeKeyAndVisible() 23 | 24 | return true 25 | } 26 | 27 | func applicationWillResignActive(_ application: UIApplication) { 28 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 29 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 30 | } 31 | 32 | func applicationDidEnterBackground(_ application: UIApplication) { 33 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 35 | } 36 | 37 | func applicationWillEnterForeground(_ application: UIApplication) { 38 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 39 | } 40 | 41 | func applicationDidBecomeActive(_ application: UIApplication) { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | func applicationWillTerminate(_ application: UIApplication) { 46 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 47 | } 48 | 49 | 50 | } 51 | 52 | -------------------------------------------------------------------------------- /YYButton/YYButton/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /YYButton/YYButton/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /YYButton/YYButton/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /YYButton/YYButton/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /YYButton/YYButton/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // YYButton 4 | // 5 | // Created by Domo on 2018/6/26. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | let ScreenWidth = UIScreen.main.bounds.width 11 | let ScreenHeight = UIScreen.main.bounds.height 12 | 13 | 14 | class ViewController: UIViewController { 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | self.view.backgroundColor = UIColor.white 19 | self.navigationItem.title = "UIButton小解" 20 | 21 | // 创建一个常规的button 22 | let button = UIButton(type:.custom) 23 | button.frame = CGRect(x:ScreenWidth/2-40, y:84, width:80, height:30) 24 | button.setTitle("FirstBtn", for: .normal) 25 | button.setTitleColor(UIColor.red, for: .normal) 26 | //无参数点击事件 27 | //button.addTarget(self, action: #selector(buttonClick), for: .touchUpInside) 28 | //带button参数传递 29 | button.addTarget(self, action: #selector(buttonClick(button:)), for: .touchUpInside) 30 | self.view.addSubview(button) 31 | 32 | //字体 33 | button.titleLabel?.font = UIFont.systemFont(ofSize: 15) 34 | //设置圆角 35 | button.layer.masksToBounds = true 36 | button.layer.cornerRadius = 5.0 37 | //设置边框 38 | button.layer.borderColor = UIColor.purple.cgColor 39 | button.layer.borderWidth = 1.5 40 | 41 | //图片文字按钮 42 | let button1 = UIButton(frame:CGRect(x:ScreenWidth/2-60, y:ScreenHeight/4, width:120, height:120)) 43 | self.view.addSubview(button1) 44 | button1.setTitle("图片按钮", for: .normal) 45 | button1.setImage(UIImage(named:"hightImage.png"), for: .normal) 46 | button1.backgroundColor = UIColor.red 47 | // 上左下右 根据自己图片和文字布局自行调整参数设置 48 | button1.imageEdgeInsets = UIEdgeInsetsMake(0, 25, 50, 0) 49 | button1.titleEdgeInsets = UIEdgeInsetsMake(0, -25, -50, 10) 50 | 51 | } 52 | //无参数点击事件点击事件 53 | // @objc func buttonClick(){ 54 | // print("点击了button") 55 | // } 56 | 57 | @objc func buttonClick(button:UIButton ){ 58 | button.isSelected = !button.isSelected 59 | if button.isSelected { 60 | button.setTitle("Selected", for: .normal) 61 | }else{ 62 | button.setTitle("NoSelected", for: .normal) 63 | } 64 | } 65 | 66 | override func didReceiveMemoryWarning() { 67 | super.didReceiveMemoryWarning() 68 | // Dispose of any resources that can be recreated. 69 | } 70 | 71 | 72 | } 73 | 74 | -------------------------------------------------------------------------------- /YYButton/YYButton/hightImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daomoer/YYSwiftLearnDemos/1fc858e6dbb0949b91fb17d7c8fecfaaadb8c7a6/YYButton/YYButton/hightImage.png -------------------------------------------------------------------------------- /YYButton/YYButtonTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /YYButton/YYButtonTests/YYButtonTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YYButtonTests.swift 3 | // YYButtonTests 4 | // 5 | // Created by Domo on 2018/6/26. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import YYButton 11 | 12 | class YYButtonTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /YYButton/YYButtonUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /YYButton/YYButtonUITests/YYButtonUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YYButtonUITests.swift 3 | // YYButtonUITests 4 | // 5 | // Created by Domo on 2018/6/26. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class YYButtonUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | // Use recording to get started writing UI tests. 33 | // Use XCTAssert and related functions to verify your tests produce the correct results. 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /YYButton/屏幕快照 2018-06-27 上午11.05.24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daomoer/YYSwiftLearnDemos/1fc858e6dbb0949b91fb17d7c8fecfaaadb8c7a6/YYButton/屏幕快照 2018-06-27 上午11.05.24.png -------------------------------------------------------------------------------- /YYCollectionView/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daomoer/YYSwiftLearnDemos/1fc858e6dbb0949b91fb17d7c8fecfaaadb8c7a6/YYCollectionView/.DS_Store -------------------------------------------------------------------------------- /YYCollectionView/YYCollectionView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /YYCollectionView/YYCollectionView/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // YYCollectionView 4 | // 5 | // Created by Domo on 2018/6/27. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | let rootVC = ViewController() 19 | let rootNav = UINavigationController.init(rootViewController: rootVC) 20 | self.window?.rootViewController = rootNav 21 | self.window?.makeKeyAndVisible() 22 | 23 | return true 24 | } 25 | 26 | func applicationWillResignActive(_ application: UIApplication) { 27 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 28 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 29 | } 30 | 31 | func applicationDidEnterBackground(_ application: UIApplication) { 32 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 33 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 34 | } 35 | 36 | func applicationWillEnterForeground(_ application: UIApplication) { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | func applicationDidBecomeActive(_ application: UIApplication) { 41 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 42 | } 43 | 44 | func applicationWillTerminate(_ application: UIApplication) { 45 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 46 | } 47 | 48 | 49 | } 50 | 51 | -------------------------------------------------------------------------------- /YYCollectionView/YYCollectionView/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /YYCollectionView/YYCollectionView/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /YYCollectionView/YYCollectionView/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /YYCollectionView/YYCollectionView/CollectionFootView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CollectionFootView.swift 3 | // YYCollectionView 4 | // 5 | // Created by Domo on 2018/6/27. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CollectionFootView: UICollectionReusableView { 12 | 13 | var view = UIView() 14 | var label = UILabel() 15 | 16 | 17 | required init?(coder aDecoder: NSCoder) { 18 | super.init(coder: aDecoder) 19 | } 20 | 21 | override init(frame: CGRect) { 22 | super.init(frame: frame) 23 | self.view = UIView.init(frame: CGRect(x:0,y:0, width:self.frame.size.width, height:self.frame.size.height)) 24 | self.addSubview(view) 25 | 26 | self.label = UILabel.init(frame: CGRect(x:10, y: 0, width:200, height:self.frame.size.height)) 27 | self.addSubview(label) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /YYCollectionView/YYCollectionView/CollectionHeaderView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CollectionHeaderView.swift 3 | // YYCollectionView 4 | // 5 | // Created by Domo on 2018/6/27. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CollectionHeaderView: UICollectionReusableView { 12 | var view = UIView() 13 | var label = UILabel() 14 | 15 | required init?(coder aDecoder: NSCoder) { 16 | super.init(coder: aDecoder) 17 | } 18 | 19 | override init(frame: CGRect) { 20 | super.init(frame: frame) 21 | self.view = UIView.init(frame: CGRect(x:0,y:0, width:self.frame.size.width, height:self.frame.size.height)) 22 | self.addSubview(view) 23 | 24 | self.label = UILabel.init(frame: CGRect(x:10, y: 0, width:200, height:self.frame.size.height)) 25 | self.addSubview(label) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /YYCollectionView/YYCollectionView/CollectionViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CollectionViewCell.swift 3 | // YYCollectionView 4 | // 5 | // Created by Domo on 2018/6/27. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CollectionViewCell: UICollectionViewCell { 12 | @IBOutlet weak var bgView: UIView! 13 | @IBOutlet weak var titleLabel: UILabel! 14 | override func awakeFromNib() { 15 | super.awakeFromNib() 16 | // Initialization code 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /YYCollectionView/YYCollectionView/CollectionViewCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /YYCollectionView/YYCollectionView/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /YYCollectionView/YYCollectionView/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // YYCollectionView 4 | // 5 | // Created by Domo on 2018/6/27. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | let ScreenWidth = UIScreen.main.bounds.width 12 | let ScreenHeight = UIScreen.main.bounds.height 13 | 14 | class ViewController: UIViewController ,UICollectionViewDataSource, UICollectionViewDelegate{ 15 | var collectionView : UICollectionView? 16 | let Identifier = "CollectionViewCell" 17 | let headerIdentifier = "CollectionHeaderView" 18 | let footIdentifier = "CollectionFootView" 19 | 20 | 21 | override func viewDidLoad() { 22 | super.viewDidLoad() 23 | self.navigationItem.title = "UICollectionView小解" 24 | self.view.backgroundColor = UIColor.white 25 | // 初始化 26 | let layout = UICollectionViewFlowLayout.init() 27 | layout.itemSize = CGSize(width: 60, height: 60) 28 | layout.minimumLineSpacing = 5 29 | layout.minimumInteritemSpacing = 5 30 | layout.scrollDirection = .vertical 31 | layout.sectionInset = UIEdgeInsets.init(top: 5, left: 5, bottom: 5, right: 5) 32 | // 设置分区头视图和尾视图宽高 33 | layout.headerReferenceSize = CGSize.init(width: ScreenWidth, height: 80) 34 | layout.footerReferenceSize = CGSize.init(width: ScreenWidth, height: 80) 35 | 36 | collectionView = UICollectionView.init(frame: CGRect(x:0, y:64, width:ScreenWidth, height:400), collectionViewLayout: layout) 37 | collectionView?.backgroundColor = UIColor.white 38 | collectionView?.delegate = self 39 | collectionView?.dataSource = self 40 | self.view.addSubview(collectionView!) 41 | 42 | // 注册cell 43 | collectionView?.register(UINib.init(nibName: "CollectionViewCell", bundle: nil), forCellWithReuseIdentifier: Identifier) 44 | // 注册headerView 45 | collectionView?.register(CollectionHeaderView.self, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: headerIdentifier) 46 | // 注册footView 47 | collectionView?.register(CollectionFootView.self, forSupplementaryViewOfKind: UICollectionElementKindSectionFooter, withReuseIdentifier: footIdentifier) 48 | 49 | } 50 | 51 | // //header高度 52 | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { 53 | return CGSize.init(width: ScreenWidth, height: 80) 54 | } 55 | //footer高度 56 | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize { 57 | return CGSize.init(width: ScreenWidth, height: 80) 58 | } 59 | 60 | //设定header和footer的方法,根据kind不同进行不同的判断即可 61 | func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { 62 | if kind == UICollectionElementKindSectionHeader{ 63 | let headerView : CollectionHeaderView = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionElementKindSectionHeader, withReuseIdentifier: headerIdentifier, for: indexPath) as! CollectionHeaderView 64 | headerView.view.backgroundColor = UIColor.red 65 | headerView.label.text = "This is HeaderView" 66 | return headerView 67 | }else{ 68 | let footView : CollectionFootView = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionElementKindSectionFooter, withReuseIdentifier: footIdentifier, for: indexPath) as! CollectionFootView 69 | footView.view.backgroundColor = UIColor.purple 70 | footView.label.text = "This is Foot" 71 | return footView 72 | } 73 | } 74 | 75 | func numberOfSections(in collectionView: UICollectionView) -> Int { 76 | return 1 77 | } 78 | 79 | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 80 | return 18 81 | } 82 | 83 | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 84 | let cell:CollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: Identifier, for: indexPath) as! CollectionViewCell 85 | cell.bgView.backgroundColor = armColor() 86 | cell.titleLabel.text = String(format:"%ditem",indexPath.row) 87 | return cell 88 | } 89 | 90 | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { 91 | print(indexPath.row) 92 | } 93 | 94 | func armColor()->UIColor{ 95 | let red = CGFloat(arc4random()%256)/255.0 96 | let green = CGFloat(arc4random()%256)/255.0 97 | let blue = CGFloat(arc4random()%256)/255.0 98 | return UIColor(red: red, green: green, blue: blue, alpha: 1.0) 99 | } 100 | 101 | 102 | override func didReceiveMemoryWarning() { 103 | super.didReceiveMemoryWarning() 104 | // Dispose of any resources that can be recreated. 105 | } 106 | } 107 | 108 | -------------------------------------------------------------------------------- /YYCollectionView/YYCollectionViewTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /YYCollectionView/YYCollectionViewTests/YYCollectionViewTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YYCollectionViewTests.swift 3 | // YYCollectionViewTests 4 | // 5 | // Created by Domo on 2018/6/27. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import YYCollectionView 11 | 12 | class YYCollectionViewTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /YYCollectionView/YYCollectionViewUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /YYCollectionView/YYCollectionViewUITests/YYCollectionViewUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YYCollectionViewUITests.swift 3 | // YYCollectionViewUITests 4 | // 5 | // Created by Domo on 2018/6/27. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class YYCollectionViewUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | // Use recording to get started writing UI tests. 33 | // Use XCTAssert and related functions to verify your tests produce the correct results. 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /YYCollectionView/屏幕快照 2018-06-27 下午4.44.50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daomoer/YYSwiftLearnDemos/1fc858e6dbb0949b91fb17d7c8fecfaaadb8c7a6/YYCollectionView/屏幕快照 2018-06-27 下午4.44.50.png -------------------------------------------------------------------------------- /YYLabel/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daomoer/YYSwiftLearnDemos/1fc858e6dbb0949b91fb17d7c8fecfaaadb8c7a6/YYLabel/.DS_Store -------------------------------------------------------------------------------- /YYLabel/Label.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daomoer/YYSwiftLearnDemos/1fc858e6dbb0949b91fb17d7c8fecfaaadb8c7a6/YYLabel/Label.png -------------------------------------------------------------------------------- /YYLabel/YYLabel.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | CFBA65B020E1DA3A00890C26 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFBA65AF20E1DA3A00890C26 /* AppDelegate.swift */; }; 11 | CFBA65B220E1DA3A00890C26 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFBA65B120E1DA3A00890C26 /* ViewController.swift */; }; 12 | CFBA65B520E1DA3A00890C26 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CFBA65B320E1DA3A00890C26 /* Main.storyboard */; }; 13 | CFBA65B720E1DA3A00890C26 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CFBA65B620E1DA3A00890C26 /* Assets.xcassets */; }; 14 | CFBA65BA20E1DA3A00890C26 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CFBA65B820E1DA3A00890C26 /* LaunchScreen.storyboard */; }; 15 | CFBA65C520E1DA3A00890C26 /* YYLabelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFBA65C420E1DA3A00890C26 /* YYLabelTests.swift */; }; 16 | CFBA65D020E1DA3A00890C26 /* YYLabelUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CFBA65CF20E1DA3A00890C26 /* YYLabelUITests.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | CFBA65C120E1DA3A00890C26 /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = CFBA65A420E1DA3A00890C26 /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = CFBA65AB20E1DA3A00890C26; 25 | remoteInfo = YYLabel; 26 | }; 27 | CFBA65CC20E1DA3A00890C26 /* PBXContainerItemProxy */ = { 28 | isa = PBXContainerItemProxy; 29 | containerPortal = CFBA65A420E1DA3A00890C26 /* Project object */; 30 | proxyType = 1; 31 | remoteGlobalIDString = CFBA65AB20E1DA3A00890C26; 32 | remoteInfo = YYLabel; 33 | }; 34 | /* End PBXContainerItemProxy section */ 35 | 36 | /* Begin PBXFileReference section */ 37 | CFBA65AC20E1DA3A00890C26 /* YYLabel.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YYLabel.app; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | CFBA65AF20E1DA3A00890C26 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 39 | CFBA65B120E1DA3A00890C26 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 40 | CFBA65B420E1DA3A00890C26 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 41 | CFBA65B620E1DA3A00890C26 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 42 | CFBA65B920E1DA3A00890C26 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 43 | CFBA65BB20E1DA3A00890C26 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | CFBA65C020E1DA3A00890C26 /* YYLabelTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = YYLabelTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | CFBA65C420E1DA3A00890C26 /* YYLabelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YYLabelTests.swift; sourceTree = ""; }; 46 | CFBA65C620E1DA3A00890C26 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 47 | CFBA65CB20E1DA3A00890C26 /* YYLabelUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = YYLabelUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 48 | CFBA65CF20E1DA3A00890C26 /* YYLabelUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YYLabelUITests.swift; sourceTree = ""; }; 49 | CFBA65D120E1DA3A00890C26 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50 | /* End PBXFileReference section */ 51 | 52 | /* Begin PBXFrameworksBuildPhase section */ 53 | CFBA65A920E1DA3A00890C26 /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | ); 58 | runOnlyForDeploymentPostprocessing = 0; 59 | }; 60 | CFBA65BD20E1DA3A00890C26 /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | CFBA65C820E1DA3A00890C26 /* Frameworks */ = { 68 | isa = PBXFrameworksBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | ); 72 | runOnlyForDeploymentPostprocessing = 0; 73 | }; 74 | /* End PBXFrameworksBuildPhase section */ 75 | 76 | /* Begin PBXGroup section */ 77 | CFBA65A320E1DA3A00890C26 = { 78 | isa = PBXGroup; 79 | children = ( 80 | CFBA65AE20E1DA3A00890C26 /* YYLabel */, 81 | CFBA65C320E1DA3A00890C26 /* YYLabelTests */, 82 | CFBA65CE20E1DA3A00890C26 /* YYLabelUITests */, 83 | CFBA65AD20E1DA3A00890C26 /* Products */, 84 | ); 85 | sourceTree = ""; 86 | }; 87 | CFBA65AD20E1DA3A00890C26 /* Products */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | CFBA65AC20E1DA3A00890C26 /* YYLabel.app */, 91 | CFBA65C020E1DA3A00890C26 /* YYLabelTests.xctest */, 92 | CFBA65CB20E1DA3A00890C26 /* YYLabelUITests.xctest */, 93 | ); 94 | name = Products; 95 | sourceTree = ""; 96 | }; 97 | CFBA65AE20E1DA3A00890C26 /* YYLabel */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | CFBA65AF20E1DA3A00890C26 /* AppDelegate.swift */, 101 | CFBA65B120E1DA3A00890C26 /* ViewController.swift */, 102 | CFBA65B320E1DA3A00890C26 /* Main.storyboard */, 103 | CFBA65B620E1DA3A00890C26 /* Assets.xcassets */, 104 | CFBA65B820E1DA3A00890C26 /* LaunchScreen.storyboard */, 105 | CFBA65BB20E1DA3A00890C26 /* Info.plist */, 106 | ); 107 | path = YYLabel; 108 | sourceTree = ""; 109 | }; 110 | CFBA65C320E1DA3A00890C26 /* YYLabelTests */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | CFBA65C420E1DA3A00890C26 /* YYLabelTests.swift */, 114 | CFBA65C620E1DA3A00890C26 /* Info.plist */, 115 | ); 116 | path = YYLabelTests; 117 | sourceTree = ""; 118 | }; 119 | CFBA65CE20E1DA3A00890C26 /* YYLabelUITests */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | CFBA65CF20E1DA3A00890C26 /* YYLabelUITests.swift */, 123 | CFBA65D120E1DA3A00890C26 /* Info.plist */, 124 | ); 125 | path = YYLabelUITests; 126 | sourceTree = ""; 127 | }; 128 | /* End PBXGroup section */ 129 | 130 | /* Begin PBXNativeTarget section */ 131 | CFBA65AB20E1DA3A00890C26 /* YYLabel */ = { 132 | isa = PBXNativeTarget; 133 | buildConfigurationList = CFBA65D420E1DA3A00890C26 /* Build configuration list for PBXNativeTarget "YYLabel" */; 134 | buildPhases = ( 135 | CFBA65A820E1DA3A00890C26 /* Sources */, 136 | CFBA65A920E1DA3A00890C26 /* Frameworks */, 137 | CFBA65AA20E1DA3A00890C26 /* Resources */, 138 | ); 139 | buildRules = ( 140 | ); 141 | dependencies = ( 142 | ); 143 | name = YYLabel; 144 | productName = YYLabel; 145 | productReference = CFBA65AC20E1DA3A00890C26 /* YYLabel.app */; 146 | productType = "com.apple.product-type.application"; 147 | }; 148 | CFBA65BF20E1DA3A00890C26 /* YYLabelTests */ = { 149 | isa = PBXNativeTarget; 150 | buildConfigurationList = CFBA65D720E1DA3A00890C26 /* Build configuration list for PBXNativeTarget "YYLabelTests" */; 151 | buildPhases = ( 152 | CFBA65BC20E1DA3A00890C26 /* Sources */, 153 | CFBA65BD20E1DA3A00890C26 /* Frameworks */, 154 | CFBA65BE20E1DA3A00890C26 /* Resources */, 155 | ); 156 | buildRules = ( 157 | ); 158 | dependencies = ( 159 | CFBA65C220E1DA3A00890C26 /* PBXTargetDependency */, 160 | ); 161 | name = YYLabelTests; 162 | productName = YYLabelTests; 163 | productReference = CFBA65C020E1DA3A00890C26 /* YYLabelTests.xctest */; 164 | productType = "com.apple.product-type.bundle.unit-test"; 165 | }; 166 | CFBA65CA20E1DA3A00890C26 /* YYLabelUITests */ = { 167 | isa = PBXNativeTarget; 168 | buildConfigurationList = CFBA65DA20E1DA3A00890C26 /* Build configuration list for PBXNativeTarget "YYLabelUITests" */; 169 | buildPhases = ( 170 | CFBA65C720E1DA3A00890C26 /* Sources */, 171 | CFBA65C820E1DA3A00890C26 /* Frameworks */, 172 | CFBA65C920E1DA3A00890C26 /* Resources */, 173 | ); 174 | buildRules = ( 175 | ); 176 | dependencies = ( 177 | CFBA65CD20E1DA3A00890C26 /* PBXTargetDependency */, 178 | ); 179 | name = YYLabelUITests; 180 | productName = YYLabelUITests; 181 | productReference = CFBA65CB20E1DA3A00890C26 /* YYLabelUITests.xctest */; 182 | productType = "com.apple.product-type.bundle.ui-testing"; 183 | }; 184 | /* End PBXNativeTarget section */ 185 | 186 | /* Begin PBXProject section */ 187 | CFBA65A420E1DA3A00890C26 /* Project object */ = { 188 | isa = PBXProject; 189 | attributes = { 190 | LastSwiftUpdateCheck = 0920; 191 | LastUpgradeCheck = 0920; 192 | ORGANIZATIONNAME = "知言网络"; 193 | TargetAttributes = { 194 | CFBA65AB20E1DA3A00890C26 = { 195 | CreatedOnToolsVersion = 9.2; 196 | ProvisioningStyle = Automatic; 197 | }; 198 | CFBA65BF20E1DA3A00890C26 = { 199 | CreatedOnToolsVersion = 9.2; 200 | ProvisioningStyle = Automatic; 201 | TestTargetID = CFBA65AB20E1DA3A00890C26; 202 | }; 203 | CFBA65CA20E1DA3A00890C26 = { 204 | CreatedOnToolsVersion = 9.2; 205 | ProvisioningStyle = Automatic; 206 | TestTargetID = CFBA65AB20E1DA3A00890C26; 207 | }; 208 | }; 209 | }; 210 | buildConfigurationList = CFBA65A720E1DA3A00890C26 /* Build configuration list for PBXProject "YYLabel" */; 211 | compatibilityVersion = "Xcode 8.0"; 212 | developmentRegion = en; 213 | hasScannedForEncodings = 0; 214 | knownRegions = ( 215 | en, 216 | Base, 217 | ); 218 | mainGroup = CFBA65A320E1DA3A00890C26; 219 | productRefGroup = CFBA65AD20E1DA3A00890C26 /* Products */; 220 | projectDirPath = ""; 221 | projectRoot = ""; 222 | targets = ( 223 | CFBA65AB20E1DA3A00890C26 /* YYLabel */, 224 | CFBA65BF20E1DA3A00890C26 /* YYLabelTests */, 225 | CFBA65CA20E1DA3A00890C26 /* YYLabelUITests */, 226 | ); 227 | }; 228 | /* End PBXProject section */ 229 | 230 | /* Begin PBXResourcesBuildPhase section */ 231 | CFBA65AA20E1DA3A00890C26 /* Resources */ = { 232 | isa = PBXResourcesBuildPhase; 233 | buildActionMask = 2147483647; 234 | files = ( 235 | CFBA65BA20E1DA3A00890C26 /* LaunchScreen.storyboard in Resources */, 236 | CFBA65B720E1DA3A00890C26 /* Assets.xcassets in Resources */, 237 | CFBA65B520E1DA3A00890C26 /* Main.storyboard in Resources */, 238 | ); 239 | runOnlyForDeploymentPostprocessing = 0; 240 | }; 241 | CFBA65BE20E1DA3A00890C26 /* Resources */ = { 242 | isa = PBXResourcesBuildPhase; 243 | buildActionMask = 2147483647; 244 | files = ( 245 | ); 246 | runOnlyForDeploymentPostprocessing = 0; 247 | }; 248 | CFBA65C920E1DA3A00890C26 /* Resources */ = { 249 | isa = PBXResourcesBuildPhase; 250 | buildActionMask = 2147483647; 251 | files = ( 252 | ); 253 | runOnlyForDeploymentPostprocessing = 0; 254 | }; 255 | /* End PBXResourcesBuildPhase section */ 256 | 257 | /* Begin PBXSourcesBuildPhase section */ 258 | CFBA65A820E1DA3A00890C26 /* Sources */ = { 259 | isa = PBXSourcesBuildPhase; 260 | buildActionMask = 2147483647; 261 | files = ( 262 | CFBA65B220E1DA3A00890C26 /* ViewController.swift in Sources */, 263 | CFBA65B020E1DA3A00890C26 /* AppDelegate.swift in Sources */, 264 | ); 265 | runOnlyForDeploymentPostprocessing = 0; 266 | }; 267 | CFBA65BC20E1DA3A00890C26 /* Sources */ = { 268 | isa = PBXSourcesBuildPhase; 269 | buildActionMask = 2147483647; 270 | files = ( 271 | CFBA65C520E1DA3A00890C26 /* YYLabelTests.swift in Sources */, 272 | ); 273 | runOnlyForDeploymentPostprocessing = 0; 274 | }; 275 | CFBA65C720E1DA3A00890C26 /* Sources */ = { 276 | isa = PBXSourcesBuildPhase; 277 | buildActionMask = 2147483647; 278 | files = ( 279 | CFBA65D020E1DA3A00890C26 /* YYLabelUITests.swift in Sources */, 280 | ); 281 | runOnlyForDeploymentPostprocessing = 0; 282 | }; 283 | /* End PBXSourcesBuildPhase section */ 284 | 285 | /* Begin PBXTargetDependency section */ 286 | CFBA65C220E1DA3A00890C26 /* PBXTargetDependency */ = { 287 | isa = PBXTargetDependency; 288 | target = CFBA65AB20E1DA3A00890C26 /* YYLabel */; 289 | targetProxy = CFBA65C120E1DA3A00890C26 /* PBXContainerItemProxy */; 290 | }; 291 | CFBA65CD20E1DA3A00890C26 /* PBXTargetDependency */ = { 292 | isa = PBXTargetDependency; 293 | target = CFBA65AB20E1DA3A00890C26 /* YYLabel */; 294 | targetProxy = CFBA65CC20E1DA3A00890C26 /* PBXContainerItemProxy */; 295 | }; 296 | /* End PBXTargetDependency section */ 297 | 298 | /* Begin PBXVariantGroup section */ 299 | CFBA65B320E1DA3A00890C26 /* Main.storyboard */ = { 300 | isa = PBXVariantGroup; 301 | children = ( 302 | CFBA65B420E1DA3A00890C26 /* Base */, 303 | ); 304 | name = Main.storyboard; 305 | sourceTree = ""; 306 | }; 307 | CFBA65B820E1DA3A00890C26 /* LaunchScreen.storyboard */ = { 308 | isa = PBXVariantGroup; 309 | children = ( 310 | CFBA65B920E1DA3A00890C26 /* Base */, 311 | ); 312 | name = LaunchScreen.storyboard; 313 | sourceTree = ""; 314 | }; 315 | /* End PBXVariantGroup section */ 316 | 317 | /* Begin XCBuildConfiguration section */ 318 | CFBA65D220E1DA3A00890C26 /* Debug */ = { 319 | isa = XCBuildConfiguration; 320 | buildSettings = { 321 | ALWAYS_SEARCH_USER_PATHS = NO; 322 | CLANG_ANALYZER_NONNULL = YES; 323 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 324 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 325 | CLANG_CXX_LIBRARY = "libc++"; 326 | CLANG_ENABLE_MODULES = YES; 327 | CLANG_ENABLE_OBJC_ARC = YES; 328 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 329 | CLANG_WARN_BOOL_CONVERSION = YES; 330 | CLANG_WARN_COMMA = YES; 331 | CLANG_WARN_CONSTANT_CONVERSION = YES; 332 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 333 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 334 | CLANG_WARN_EMPTY_BODY = YES; 335 | CLANG_WARN_ENUM_CONVERSION = YES; 336 | CLANG_WARN_INFINITE_RECURSION = YES; 337 | CLANG_WARN_INT_CONVERSION = YES; 338 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 339 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 340 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 341 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 342 | CLANG_WARN_STRICT_PROTOTYPES = YES; 343 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 344 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 345 | CLANG_WARN_UNREACHABLE_CODE = YES; 346 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 347 | CODE_SIGN_IDENTITY = "iPhone Developer"; 348 | COPY_PHASE_STRIP = NO; 349 | DEBUG_INFORMATION_FORMAT = dwarf; 350 | ENABLE_STRICT_OBJC_MSGSEND = YES; 351 | ENABLE_TESTABILITY = YES; 352 | GCC_C_LANGUAGE_STANDARD = gnu11; 353 | GCC_DYNAMIC_NO_PIC = NO; 354 | GCC_NO_COMMON_BLOCKS = YES; 355 | GCC_OPTIMIZATION_LEVEL = 0; 356 | GCC_PREPROCESSOR_DEFINITIONS = ( 357 | "DEBUG=1", 358 | "$(inherited)", 359 | ); 360 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 361 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 362 | GCC_WARN_UNDECLARED_SELECTOR = YES; 363 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 364 | GCC_WARN_UNUSED_FUNCTION = YES; 365 | GCC_WARN_UNUSED_VARIABLE = YES; 366 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 367 | MTL_ENABLE_DEBUG_INFO = YES; 368 | ONLY_ACTIVE_ARCH = YES; 369 | SDKROOT = iphoneos; 370 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 371 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 372 | }; 373 | name = Debug; 374 | }; 375 | CFBA65D320E1DA3A00890C26 /* Release */ = { 376 | isa = XCBuildConfiguration; 377 | buildSettings = { 378 | ALWAYS_SEARCH_USER_PATHS = NO; 379 | CLANG_ANALYZER_NONNULL = YES; 380 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 381 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 382 | CLANG_CXX_LIBRARY = "libc++"; 383 | CLANG_ENABLE_MODULES = YES; 384 | CLANG_ENABLE_OBJC_ARC = YES; 385 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 386 | CLANG_WARN_BOOL_CONVERSION = YES; 387 | CLANG_WARN_COMMA = YES; 388 | CLANG_WARN_CONSTANT_CONVERSION = YES; 389 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 390 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 391 | CLANG_WARN_EMPTY_BODY = YES; 392 | CLANG_WARN_ENUM_CONVERSION = YES; 393 | CLANG_WARN_INFINITE_RECURSION = YES; 394 | CLANG_WARN_INT_CONVERSION = YES; 395 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 396 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 397 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 398 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 399 | CLANG_WARN_STRICT_PROTOTYPES = YES; 400 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 401 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 402 | CLANG_WARN_UNREACHABLE_CODE = YES; 403 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 404 | CODE_SIGN_IDENTITY = "iPhone Developer"; 405 | COPY_PHASE_STRIP = NO; 406 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 407 | ENABLE_NS_ASSERTIONS = NO; 408 | ENABLE_STRICT_OBJC_MSGSEND = YES; 409 | GCC_C_LANGUAGE_STANDARD = gnu11; 410 | GCC_NO_COMMON_BLOCKS = YES; 411 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 412 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 413 | GCC_WARN_UNDECLARED_SELECTOR = YES; 414 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 415 | GCC_WARN_UNUSED_FUNCTION = YES; 416 | GCC_WARN_UNUSED_VARIABLE = YES; 417 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 418 | MTL_ENABLE_DEBUG_INFO = NO; 419 | SDKROOT = iphoneos; 420 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 421 | VALIDATE_PRODUCT = YES; 422 | }; 423 | name = Release; 424 | }; 425 | CFBA65D520E1DA3A00890C26 /* Debug */ = { 426 | isa = XCBuildConfiguration; 427 | buildSettings = { 428 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 429 | CODE_SIGN_STYLE = Automatic; 430 | INFOPLIST_FILE = YYLabel/Info.plist; 431 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 432 | PRODUCT_BUNDLE_IDENTIFIER = com.zhiyan.YYLabel; 433 | PRODUCT_NAME = "$(TARGET_NAME)"; 434 | SWIFT_VERSION = 4.0; 435 | TARGETED_DEVICE_FAMILY = "1,2"; 436 | }; 437 | name = Debug; 438 | }; 439 | CFBA65D620E1DA3A00890C26 /* Release */ = { 440 | isa = XCBuildConfiguration; 441 | buildSettings = { 442 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 443 | CODE_SIGN_STYLE = Automatic; 444 | INFOPLIST_FILE = YYLabel/Info.plist; 445 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 446 | PRODUCT_BUNDLE_IDENTIFIER = com.zhiyan.YYLabel; 447 | PRODUCT_NAME = "$(TARGET_NAME)"; 448 | SWIFT_VERSION = 4.0; 449 | TARGETED_DEVICE_FAMILY = "1,2"; 450 | }; 451 | name = Release; 452 | }; 453 | CFBA65D820E1DA3A00890C26 /* Debug */ = { 454 | isa = XCBuildConfiguration; 455 | buildSettings = { 456 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 457 | BUNDLE_LOADER = "$(TEST_HOST)"; 458 | CODE_SIGN_STYLE = Automatic; 459 | INFOPLIST_FILE = YYLabelTests/Info.plist; 460 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 461 | PRODUCT_BUNDLE_IDENTIFIER = com.zhiyan.YYLabelTests; 462 | PRODUCT_NAME = "$(TARGET_NAME)"; 463 | SWIFT_VERSION = 4.0; 464 | TARGETED_DEVICE_FAMILY = "1,2"; 465 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/YYLabel.app/YYLabel"; 466 | }; 467 | name = Debug; 468 | }; 469 | CFBA65D920E1DA3A00890C26 /* Release */ = { 470 | isa = XCBuildConfiguration; 471 | buildSettings = { 472 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 473 | BUNDLE_LOADER = "$(TEST_HOST)"; 474 | CODE_SIGN_STYLE = Automatic; 475 | INFOPLIST_FILE = YYLabelTests/Info.plist; 476 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 477 | PRODUCT_BUNDLE_IDENTIFIER = com.zhiyan.YYLabelTests; 478 | PRODUCT_NAME = "$(TARGET_NAME)"; 479 | SWIFT_VERSION = 4.0; 480 | TARGETED_DEVICE_FAMILY = "1,2"; 481 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/YYLabel.app/YYLabel"; 482 | }; 483 | name = Release; 484 | }; 485 | CFBA65DB20E1DA3A00890C26 /* Debug */ = { 486 | isa = XCBuildConfiguration; 487 | buildSettings = { 488 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 489 | CODE_SIGN_STYLE = Automatic; 490 | INFOPLIST_FILE = YYLabelUITests/Info.plist; 491 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 492 | PRODUCT_BUNDLE_IDENTIFIER = com.zhiyan.YYLabelUITests; 493 | PRODUCT_NAME = "$(TARGET_NAME)"; 494 | SWIFT_VERSION = 4.0; 495 | TARGETED_DEVICE_FAMILY = "1,2"; 496 | TEST_TARGET_NAME = YYLabel; 497 | }; 498 | name = Debug; 499 | }; 500 | CFBA65DC20E1DA3A00890C26 /* Release */ = { 501 | isa = XCBuildConfiguration; 502 | buildSettings = { 503 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 504 | CODE_SIGN_STYLE = Automatic; 505 | INFOPLIST_FILE = YYLabelUITests/Info.plist; 506 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 507 | PRODUCT_BUNDLE_IDENTIFIER = com.zhiyan.YYLabelUITests; 508 | PRODUCT_NAME = "$(TARGET_NAME)"; 509 | SWIFT_VERSION = 4.0; 510 | TARGETED_DEVICE_FAMILY = "1,2"; 511 | TEST_TARGET_NAME = YYLabel; 512 | }; 513 | name = Release; 514 | }; 515 | /* End XCBuildConfiguration section */ 516 | 517 | /* Begin XCConfigurationList section */ 518 | CFBA65A720E1DA3A00890C26 /* Build configuration list for PBXProject "YYLabel" */ = { 519 | isa = XCConfigurationList; 520 | buildConfigurations = ( 521 | CFBA65D220E1DA3A00890C26 /* Debug */, 522 | CFBA65D320E1DA3A00890C26 /* Release */, 523 | ); 524 | defaultConfigurationIsVisible = 0; 525 | defaultConfigurationName = Release; 526 | }; 527 | CFBA65D420E1DA3A00890C26 /* Build configuration list for PBXNativeTarget "YYLabel" */ = { 528 | isa = XCConfigurationList; 529 | buildConfigurations = ( 530 | CFBA65D520E1DA3A00890C26 /* Debug */, 531 | CFBA65D620E1DA3A00890C26 /* Release */, 532 | ); 533 | defaultConfigurationIsVisible = 0; 534 | defaultConfigurationName = Release; 535 | }; 536 | CFBA65D720E1DA3A00890C26 /* Build configuration list for PBXNativeTarget "YYLabelTests" */ = { 537 | isa = XCConfigurationList; 538 | buildConfigurations = ( 539 | CFBA65D820E1DA3A00890C26 /* Debug */, 540 | CFBA65D920E1DA3A00890C26 /* Release */, 541 | ); 542 | defaultConfigurationIsVisible = 0; 543 | defaultConfigurationName = Release; 544 | }; 545 | CFBA65DA20E1DA3A00890C26 /* Build configuration list for PBXNativeTarget "YYLabelUITests" */ = { 546 | isa = XCConfigurationList; 547 | buildConfigurations = ( 548 | CFBA65DB20E1DA3A00890C26 /* Debug */, 549 | CFBA65DC20E1DA3A00890C26 /* Release */, 550 | ); 551 | defaultConfigurationIsVisible = 0; 552 | defaultConfigurationName = Release; 553 | }; 554 | /* End XCConfigurationList section */ 555 | }; 556 | rootObject = CFBA65A420E1DA3A00890C26 /* Project object */; 557 | } 558 | -------------------------------------------------------------------------------- /YYLabel/YYLabel.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /YYLabel/YYLabel/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // YYLabel 4 | // 5 | // Created by Domo on 2018/6/26. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | 12 | 13 | @UIApplicationMain 14 | class AppDelegate: UIResponder, UIApplicationDelegate { 15 | 16 | var window: UIWindow? 17 | 18 | 19 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 20 | // Override point for customization after application launch. 21 | 22 | return true 23 | } 24 | 25 | func applicationWillResignActive(_ application: UIApplication) { 26 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 27 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 28 | } 29 | 30 | func applicationDidEnterBackground(_ application: UIApplication) { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | func applicationWillEnterForeground(_ application: UIApplication) { 36 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 37 | } 38 | 39 | func applicationDidBecomeActive(_ application: UIApplication) { 40 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 41 | } 42 | 43 | func applicationWillTerminate(_ application: UIApplication) { 44 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 45 | } 46 | 47 | 48 | } 49 | 50 | -------------------------------------------------------------------------------- /YYLabel/YYLabel/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /YYLabel/YYLabel/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /YYLabel/YYLabel/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /YYLabel/YYLabel/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /YYLabel/YYLabel/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // YYLabel 4 | // 5 | // Created by Domo on 2018/6/26. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | let ScreenWidth = UIScreen.main.bounds.width 12 | let ScreenHeight = UIScreen.main.bounds.height 13 | 14 | class ViewController: UIViewController { 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | //常规创建 19 | self.view.backgroundColor = UIColor.white 20 | let label = UILabel(frame:CGRect(x:10, y:20, width:ScreenWidth-20, height:ScreenHeight/4)) 21 | label.backgroundColor = UIColor.lightGray 22 | label.text = "这是一条测试的显示数据,this is a test data,但是还不够长,suo yi yao gei ta jia chang yi dian dian" 23 | self.view.addSubview(label) 24 | 25 | //label属性 26 | // 颜色 27 | label.textColor = UIColor.red 28 | // 字体 29 | label.font = UIFont.systemFont(ofSize: 24) 30 | // 对齐方式 31 | label.textAlignment = NSTextAlignment.center 32 | // 多行显示 33 | label.numberOfLines = 3 34 | // 阴影 35 | label.shadowColor = UIColor.yellow 36 | label.shadowOffset = CGSize.init(width:2, height:2) 37 | 38 | label.lineBreakMode = NSLineBreakMode.byTruncatingTail 39 | // 高亮 40 | label.isHighlighted = true 41 | label.highlightedTextColor = UIColor.green 42 | 43 | // 富文本 44 | let attributeString = NSMutableAttributedString.init(string: "这是一条测试富文本的字符串") 45 | //从文本0开始6个字符字体HelveticaNeue-Bold,16号 46 | attributeString.addAttribute(NSAttributedStringKey.font, value: UIFont.init(name: "HelveticaNeue-Bold", size: 23) ?? UIFont.boldSystemFont(ofSize: 23), range: NSRange.init(location: 0, length: 6)) 47 | //设置富文本字体颜色 48 | attributeString.addAttribute(NSAttributedStringKey.foregroundColor, value: UIColor.brown, range: NSMakeRange(0, 6)) 49 | //设置文字背景颜色 50 | attributeString.addAttribute(NSAttributedStringKey.backgroundColor, value: UIColor.red, range: NSMakeRange(6, 5)) 51 | label.attributedText = attributeString 52 | 53 | 54 | } 55 | 56 | override func didReceiveMemoryWarning() { 57 | super.didReceiveMemoryWarning() 58 | // Dispose of any resources that can be recreated. 59 | } 60 | 61 | 62 | } 63 | 64 | -------------------------------------------------------------------------------- /YYLabel/YYLabelTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /YYLabel/YYLabelTests/YYLabelTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YYLabelTests.swift 3 | // YYLabelTests 4 | // 5 | // Created by Domo on 2018/6/26. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import YYLabel 11 | 12 | class YYLabelTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /YYLabel/YYLabelUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /YYLabel/YYLabelUITests/YYLabelUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YYLabelUITests.swift 3 | // YYLabelUITests 4 | // 5 | // Created by Domo on 2018/6/26. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class YYLabelUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | // Use recording to get started writing UI tests. 33 | // Use XCTAssert and related functions to verify your tests produce the correct results. 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /YYTableView/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daomoer/YYSwiftLearnDemos/1fc858e6dbb0949b91fb17d7c8fecfaaadb8c7a6/YYTableView/.DS_Store -------------------------------------------------------------------------------- /YYTableView/YYTableView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /YYTableView/YYTableView.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /YYTableView/YYTableView/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daomoer/YYSwiftLearnDemos/1fc858e6dbb0949b91fb17d7c8fecfaaadb8c7a6/YYTableView/YYTableView/.DS_Store -------------------------------------------------------------------------------- /YYTableView/YYTableView/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // YYTableView 4 | // 5 | // Created by Domo on 2018/6/27. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | let rootVC = ViewController() 19 | let rootNav = UINavigationController.init(rootViewController: rootVC) 20 | self.window?.rootViewController = rootNav 21 | self.window?.makeKeyAndVisible() 22 | 23 | return true 24 | } 25 | 26 | func applicationWillResignActive(_ application: UIApplication) { 27 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 28 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 29 | } 30 | 31 | func applicationDidEnterBackground(_ application: UIApplication) { 32 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 33 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 34 | } 35 | 36 | func applicationWillEnterForeground(_ application: UIApplication) { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | func applicationDidBecomeActive(_ application: UIApplication) { 41 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 42 | } 43 | 44 | func applicationWillTerminate(_ application: UIApplication) { 45 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 46 | } 47 | 48 | 49 | } 50 | 51 | -------------------------------------------------------------------------------- /YYTableView/YYTableView/Assets.xcassets/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daomoer/YYSwiftLearnDemos/1fc858e6dbb0949b91fb17d7c8fecfaaadb8c7a6/YYTableView/YYTableView/Assets.xcassets/.DS_Store -------------------------------------------------------------------------------- /YYTableView/YYTableView/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /YYTableView/YYTableView/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /YYTableView/YYTableView/Assets.xcassets/image.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "经典@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /YYTableView/YYTableView/Assets.xcassets/image.imageset/经典@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daomoer/YYSwiftLearnDemos/1fc858e6dbb0949b91fb17d7c8fecfaaadb8c7a6/YYTableView/YYTableView/Assets.xcassets/image.imageset/经典@2x.png -------------------------------------------------------------------------------- /YYTableView/YYTableView/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /YYTableView/YYTableView/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /YYTableView/YYTableView/CustomCellController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CustomCellController.swift 3 | // YYTableView 4 | // 5 | // Created by Domo on 2018/6/27. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CustomCellController: UITableViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | } 17 | // MARK: - Table view data source 18 | 19 | override func numberOfSections(in tableView: UITableView) -> Int { 20 | return 1 21 | } 22 | 23 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 24 | return 5 25 | } 26 | 27 | override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 28 | return 80 29 | } 30 | 31 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 32 | let identifier = "CustomCell" 33 | let cell = CustomTableViewCell.init(style: UITableViewCellStyle.default, reuseIdentifier: identifier) 34 | cell.setValueForCell() 35 | return cell 36 | } 37 | 38 | 39 | /* 40 | // Override to support conditional editing of the table view. 41 | override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { 42 | // Return false if you do not want the specified item to be editable. 43 | return true 44 | } 45 | */ 46 | 47 | /* 48 | // Override to support editing the table view. 49 | override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) { 50 | if editingStyle == .delete { 51 | // Delete the row from the data source 52 | tableView.deleteRows(at: [indexPath], with: .fade) 53 | } else if editingStyle == .insert { 54 | // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view 55 | } 56 | } 57 | */ 58 | 59 | /* 60 | // Override to support rearranging the table view. 61 | override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) { 62 | 63 | } 64 | */ 65 | 66 | /* 67 | // Override to support conditional rearranging of the table view. 68 | override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool { 69 | // Return false if you do not want the item to be re-orderable. 70 | return true 71 | } 72 | */ 73 | 74 | /* 75 | // MARK: - Navigation 76 | 77 | // In a storyboard-based application, you will often want to do a little preparation before navigation 78 | override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 79 | // Get the new view controller using segue.destinationViewController. 80 | // Pass the selected object to the new view controller. 81 | } 82 | */ 83 | 84 | } 85 | -------------------------------------------------------------------------------- /YYTableView/YYTableView/CustomTableViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CustomTableViewCell.swift 3 | // YYTableView 4 | // 5 | // Created by Domo on 2018/6/27. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | // 自定义cell 11 | class CustomTableViewCell: UITableViewCell { 12 | var iconImage : UIImageView? 13 | var titleLabel : UILabel? 14 | var subTitleLabel : UILabel? 15 | 16 | required init?(coder aDecoder: NSCoder) { 17 | super.init(coder: aDecoder) 18 | } 19 | 20 | override init(style: UITableViewCellStyle, reuseIdentifier: String?) { 21 | super.init(style: style, reuseIdentifier: reuseIdentifier) 22 | self.setUpUI() 23 | } 24 | 25 | func setUpUI(){ 26 | // 图片 27 | iconImage = UIImageView(frame: CGRect(x:10, y: 10, width:60, height: 60)) 28 | self.addSubview(iconImage!) 29 | 30 | // 大标题 31 | titleLabel = UILabel(frame: CGRect(x:(iconImage?.frame.size.width)!+20, y:10, width: self.frame.size.width-(iconImage?.frame.size.width)!+20, height:30)) 32 | titleLabel?.textColor = UIColor.red 33 | self.addSubview(titleLabel!) 34 | 35 | // 副标题 36 | subTitleLabel = UILabel(frame: CGRect(x:(iconImage?.frame.size.width)!+20, y:(titleLabel?.frame.size.height)!+20, width:self.frame.size.width-(iconImage?.frame.size.width)!+20, height: 30)) 37 | subTitleLabel?.font = UIFont.systemFont(ofSize: 14) 38 | subTitleLabel?.textColor = UIColor.purple 39 | self.addSubview(subTitleLabel!) 40 | } 41 | 42 | // 给cell赋值,项目中一般使用model,我这里直接写死了 43 | func setValueForCell(){ 44 | iconImage?.image = UIImage(named:"image") 45 | titleLabel?.text = "大大大大的标题" 46 | subTitleLabel?.text = "副副副副的标题" 47 | } 48 | 49 | 50 | override func awakeFromNib() { 51 | super.awakeFromNib() 52 | // Initialization code 53 | } 54 | 55 | override func setSelected(_ selected: Bool, animated: Bool) { 56 | super.setSelected(selected, animated: animated) 57 | 58 | // Configure the view for the selected state 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /YYTableView/YYTableView/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /YYTableView/YYTableView/NibCellController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NibCellController.swift 3 | // YYTableView 4 | // 5 | // Created by Domo on 2018/6/27. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class NibCellController: UIViewController ,UITableViewDataSource, UITableViewDelegate{ 12 | 13 | let identifier = "NibTableViewCell" 14 | var tableView : UITableView? 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | self.view.backgroundColor = UIColor.white 19 | tableView = UITableView(frame:CGRect(x:0, y:0, width:UIScreen.main.bounds.width, height:UIScreen.main.bounds.height)) 20 | tableView?.delegate = self 21 | tableView?.dataSource = self 22 | self.view.addSubview(tableView!) 23 | // 注册nib 24 | let nib = UINib.init(nibName: "NibTableViewCell", bundle: nil) 25 | tableView?.register(nib, forCellReuseIdentifier: identifier) 26 | } 27 | 28 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 29 | return 10 30 | } 31 | 32 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 33 | return 80 34 | } 35 | 36 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 37 | let cell = tableView.dequeueReusableCell(withIdentifier: identifier) 38 | return cell! 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /YYTableView/YYTableView/NibTableViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NibTableViewCell.swift 3 | // YYTableView 4 | // 5 | // Created by Domo on 2018/6/27. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class NibTableViewCell: UITableViewCell { 12 | 13 | @IBOutlet weak var iconImage: UIImageView! 14 | @IBOutlet weak var titleLabel: UILabel! 15 | @IBOutlet weak var subTitleLabel: UILabel! 16 | override func awakeFromNib() { 17 | super.awakeFromNib() 18 | // Initialization code 19 | } 20 | 21 | override func setSelected(_ selected: Bool, animated: Bool) { 22 | super.setSelected(selected, animated: animated) 23 | 24 | // Configure the view for the selected state 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /YYTableView/YYTableView/NibTableViewCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 40 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /YYTableView/YYTableView/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // YYTableView 4 | // 5 | // Created by Domo on 2018/6/27. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate{ 12 | 13 | var tableView:UITableView! 14 | var array:[String] = ["纯代码自定义cell", "nib自定义cell"] 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | self.navigationItem.title = "UITableIView小解" 18 | self.view.backgroundColor = UIColor.white 19 | tableView = UITableView(frame:CGRect(x:0, y:0, width:UIScreen.main.bounds.width, height:UIScreen.main.bounds.height)) 20 | tableView.delegate = self 21 | tableView.dataSource = self 22 | self.view.addSubview(tableView) 23 | } 24 | // 每个分区行数(默认分区为一个) 25 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 26 | return array.count 27 | } 28 | // 行高 29 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 30 | return 60.0 31 | } 32 | // cell 33 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 34 | let cell = UITableViewCell.init(style: UITableViewCellStyle.default, reuseIdentifier: "CellIdentifier") 35 | cell.textLabel?.text = array[indexPath.row] 36 | return cell 37 | } 38 | // cell点击事件处理 39 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 40 | switch indexPath.row { 41 | case 0: 42 | let vc = CustomCellController() 43 | self.navigationController?.pushViewController(vc, animated: true) 44 | break 45 | case 1: 46 | let vc = NibCellController() 47 | self.navigationController?.pushViewController(vc, animated: true) 48 | break 49 | default: 50 | 51 | break 52 | } 53 | } 54 | } 55 | 56 | -------------------------------------------------------------------------------- /YYTableView/YYTableViewTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /YYTableView/YYTableViewTests/YYTableViewTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YYTableViewTests.swift 3 | // YYTableViewTests 4 | // 5 | // Created by Domo on 2018/6/27. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import YYTableView 11 | 12 | class YYTableViewTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /YYTableView/YYTableViewUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /YYTableView/YYTableViewUITests/YYTableViewUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YYTableViewUITests.swift 3 | // YYTableViewUITests 4 | // 5 | // Created by Domo on 2018/6/27. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class YYTableViewUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | // Use recording to get started writing UI tests. 33 | // Use XCTAssert and related functions to verify your tests produce the correct results. 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /YYTableView/屏幕快照 2018-06-27 下午2.14.27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daomoer/YYSwiftLearnDemos/1fc858e6dbb0949b91fb17d7c8fecfaaadb8c7a6/YYTableView/屏幕快照 2018-06-27 下午2.14.27.png -------------------------------------------------------------------------------- /YYTextField/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daomoer/YYSwiftLearnDemos/1fc858e6dbb0949b91fb17d7c8fecfaaadb8c7a6/YYTextField/.DS_Store -------------------------------------------------------------------------------- /YYTextField/TextField.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daomoer/YYSwiftLearnDemos/1fc858e6dbb0949b91fb17d7c8fecfaaadb8c7a6/YYTextField/TextField.png -------------------------------------------------------------------------------- /YYTextField/YYTextField.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /YYTextField/YYTextField/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // YYTextField 4 | // 5 | // Created by Domo on 2018/6/26. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | let rootVC = ViewController() 19 | let rootNAV = UINavigationController.init(rootViewController: rootVC) 20 | self.window?.rootViewController = rootNAV 21 | self.window?.makeKeyAndVisible() 22 | 23 | return true 24 | } 25 | 26 | func applicationWillResignActive(_ application: UIApplication) { 27 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 28 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 29 | } 30 | 31 | func applicationDidEnterBackground(_ application: UIApplication) { 32 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 33 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 34 | } 35 | 36 | func applicationWillEnterForeground(_ application: UIApplication) { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | func applicationDidBecomeActive(_ application: UIApplication) { 41 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 42 | } 43 | 44 | func applicationWillTerminate(_ application: UIApplication) { 45 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 46 | } 47 | 48 | 49 | } 50 | 51 | -------------------------------------------------------------------------------- /YYTextField/YYTextField/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /YYTextField/YYTextField/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /YYTextField/YYTextField/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /YYTextField/YYTextField/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /YYTextField/YYTextField/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // YYTextField 4 | // 5 | // Created by Domo on 2018/6/26. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController, UITextFieldDelegate { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | self.navigationItem.title = "UITextField小解" 16 | self.view.backgroundColor = UIColor.white 17 | 18 | let phoneTF = UITextField.init(frame: CGRect(x:15, y:400, width:UIScreen.main.bounds.width-30, height:30)) 19 | self.view.addSubview(phoneTF) 20 | phoneTF.delegate = self 21 | // 属性设置 22 | phoneTF.placeholder = "水印文字" 23 | //字体颜色 24 | phoneTF.textColor = UIColor.purple 25 | //字体大小 26 | phoneTF.font = UIFont.systemFont(ofSize: 16) 27 | //文字是否可以缩小,缩小到指定字号不再缩小 28 | phoneTF.adjustsFontSizeToFitWidth = true 29 | // 文字最小字号 30 | phoneTF.minimumFontSize = 12 31 | //设置是否加密模式 32 | phoneTF.isSecureTextEntry = true 33 | //记录之前输入的内容 34 | phoneTF.autocorrectionType = UITextAutocorrectionType.no 35 | 36 | //设置边框样式 37 | phoneTF.borderStyle = UITextBorderStyle.roundedRect 38 | /* 39 | phoneTF.borderStyle = UITextBorderStyle.none 40 | phoneTF.borderStyle = UITextBorderStyle.line 41 | phoneTF.borderStyle = UITextBorderStyle.bezel 42 | */ 43 | 44 | // 文字内容对齐方式 45 | phoneTF.textAlignment = NSTextAlignment.center 46 | /* 47 | phoneTF.textAlignment = NSTextAlignment.left 48 | phoneTF.textAlignment = NSTextAlignment.right 49 | phoneTF.textAlignment = NSTextAlignment.justified 50 | phoneTF.textAlignment = NSTextAlignment.natural 51 | */ 52 | 53 | // 内容水平对齐方式 54 | phoneTF.contentHorizontalAlignment = UIControlContentHorizontalAlignment.center 55 | /* 56 | phoneTF.contentHorizontalAlignment = UIControlContentHorizontalAlignment.left 57 | phoneTF.contentHorizontalAlignment = UIControlContentHorizontalAlignment.right 58 | phoneTF.contentHorizontalAlignment = UIControlContentHorizontalAlignment.fill 59 | */ 60 | 61 | //内容垂直对齐方式 62 | phoneTF.contentVerticalAlignment = UIControlContentVerticalAlignment.center 63 | /* 64 | phoneTF.contentVerticalAlignment = UIControlContentVerticalAlignment.top 65 | phoneTF.contentVerticalAlignment = UIControlContentVerticalAlignment.bottom 66 | phoneTF.contentVerticalAlignment = UIControlContentVerticalAlignment.fill 67 | */ 68 | 69 | // 设置返回按钮样式 70 | phoneTF.returnKeyType = UIReturnKeyType.done 71 | /* 72 | phoneTF.returnKeyType = UIReturnKeyType.default 73 | phoneTF.returnKeyType = UIReturnKeyType.go 74 | phoneTF.returnKeyType = UIReturnKeyType.google 75 | phoneTF.returnKeyType = UIReturnKeyType.join 76 | phoneTF.returnKeyType = UIReturnKeyType.next 77 | phoneTF.returnKeyType = UIReturnKeyType.route 78 | phoneTF.returnKeyType = UIReturnKeyType.search 79 | phoneTF.returnKeyType = UIReturnKeyType.send 80 | phoneTF.returnKeyType = UIReturnKeyType.yahoo 81 | */ 82 | 83 | // 设置键盘样式 84 | phoneTF.keyboardType = UIKeyboardType.numbersAndPunctuation 85 | /* 86 | phoneTF.keyboardType = UIKeyboardType.default 87 | phoneTF.keyboardType = UIKeyboardType.asciiCapable 88 | phoneTF.keyboardType = UIKeyboardType.emailAddress 89 | phoneTF.keyboardType = UIKeyboardType.URL 90 | phoneTF.keyboardType = UIKeyboardType.numberPad 91 | phoneTF.keyboardType = UIKeyboardType.phonePad 92 | phoneTF.keyboardType = UIKeyboardType.namePhonePad 93 | */ 94 | 95 | // 设置键盘风格 96 | phoneTF.keyboardAppearance = UIKeyboardAppearance.light 97 | /* 98 | phoneTF.keyboardAppearance = UIKeyboardAppearance.default 99 | phoneTF.keyboardAppearance = UIKeyboardAppearance.dark 100 | phoneTF.keyboardAppearance = UIKeyboardAppearance.alert 101 | */ 102 | // 设置清除按钮 103 | phoneTF.clearButtonMode = UITextFieldViewMode.always 104 | /* 105 | phoneTF.clearButtonMode = UITextFieldViewMode.never 106 | phoneTF.clearButtonMode = UITextFieldViewMode.whileEditing 107 | phoneTF.clearButtonMode = UITextFieldViewMode.unlessEditing 108 | */ 109 | 110 | //设置首字母是否大写 111 | phoneTF.autocapitalizationType = UITextAutocapitalizationType.none 112 | /* 113 | phoneTF.autocapitalizationType = UITextAutocapitalizationType.words 114 | phoneTF.autocapitalizationType = UITextAutocapitalizationType.sentences 115 | phoneTF.autocapitalizationType = UITextAutocapitalizationType.allCharacters 116 | */ 117 | //设置输入框左侧头像 118 | let hadeimage = UIImageView.init(frame:CGRect(x:0, y:0, width:25, height:30)) 119 | hadeimage.image = UIImage.init(named: "testImage.png") 120 | phoneTF.leftView = hadeimage; 121 | 122 | //设置左侧视图模式 123 | phoneTF.leftViewMode = UITextFieldViewMode.always; 124 | /* 125 | textField.leftViewMode = UITextFieldViewMode.whileEditing; 126 | textField.leftViewMode = UITextFieldViewMode.unlessEditing; 127 | textField.leftViewMode = UITextFieldViewMode.none; 128 | */ 129 | } 130 | 131 | func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool { 132 | //返回一个BOOL值,指定是否循序文本字段开始编辑 133 | return true; 134 | } 135 | 136 | func textFieldShouldEndEditing(_ textField: UITextField) -> Bool { 137 | //返回BOOL值,指定是否允许文本字段结束编辑,当编辑结束,文本字段会让出first responder 138 | //要想在用户结束编辑时阻止文本字段消失,可以返回NO 139 | //这对一些文本字段必须始终保持活跃状态的程序很有用,比如即时消息 140 | return false; 141 | } 142 | 143 | func textFieldDidBeginEditing(_ textField: UITextField) { 144 | //开始编辑时触发,文本字段将成为first responder 145 | } 146 | 147 | func textFieldDidEndEditing(_ textField: UITextField) { 148 | 149 | } 150 | 151 | func textFieldShouldClear(_ textField: UITextField) -> Bool { 152 | //返回一个BOOL值指明是否允许根据用户请求清除内容 153 | //可以设置在特定条件下才允许清除内容 154 | return true; 155 | } 156 | 157 | func textFieldShouldReturn(_ textField: UITextField) -> Bool { 158 | //返回一个BOOL值,指明是否允许在按下回车键时结束编辑 159 | //如果允许要调用resignFirstResponder 方法,这回导致结束编辑,而键盘会被收起[textField resignFirstResponder]; 160 | //查一下resign这个单词的意思就明白这个方法了 161 | return true; 162 | } 163 | 164 | func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { 165 | //当用户使用自动更正功能,把输入的文字修改为推荐的文字时,就会调用这个方法。 166 | //这对于想要加入撤销选项的应用程序特别有用 167 | //可以跟踪字段内所做的最后一次修改,也可以对所有编辑做日志记录,用作审计用途。 168 | //要防止文字被改变可以返回NO 169 | //这个方法的参数中有一个NSRange对象,指明了被改变文字的位置,建议修改的文本也在其中 170 | return true; 171 | } 172 | 173 | override func didReceiveMemoryWarning() { 174 | super.didReceiveMemoryWarning() 175 | // Dispose of any resources that can be recreated. 176 | } 177 | 178 | 179 | } 180 | 181 | -------------------------------------------------------------------------------- /YYTextField/YYTextField/testImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daomoer/YYSwiftLearnDemos/1fc858e6dbb0949b91fb17d7c8fecfaaadb8c7a6/YYTextField/YYTextField/testImage.png -------------------------------------------------------------------------------- /YYTextField/YYTextFieldTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /YYTextField/YYTextFieldTests/YYTextFieldTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YYTextFieldTests.swift 3 | // YYTextFieldTests 4 | // 5 | // Created by Domo on 2018/6/26. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import YYTextField 11 | 12 | class YYTextFieldTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /YYTextField/YYTextFieldUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /YYTextField/YYTextFieldUITests/YYTextFieldUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YYTextFieldUITests.swift 3 | // YYTextFieldUITests 4 | // 5 | // Created by Domo on 2018/6/26. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class YYTextFieldUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | // Use recording to get started writing UI tests. 33 | // Use XCTAssert and related functions to verify your tests produce the correct results. 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /YYUITextView/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daomoer/YYSwiftLearnDemos/1fc858e6dbb0949b91fb17d7c8fecfaaadb8c7a6/YYUITextView/.DS_Store -------------------------------------------------------------------------------- /YYUITextView/YYUITextView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /YYUITextView/YYUITextView/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // YYUITextView 4 | // 5 | // Created by Domo on 2018/6/27. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | let rootVC = ViewController() 19 | let rooNAV = UINavigationController.init(rootViewController: rootVC) 20 | self.window?.rootViewController = rooNAV 21 | self.window?.makeKeyAndVisible() 22 | 23 | return true 24 | } 25 | 26 | func applicationWillResignActive(_ application: UIApplication) { 27 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 28 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 29 | } 30 | 31 | func applicationDidEnterBackground(_ application: UIApplication) { 32 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 33 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 34 | } 35 | 36 | func applicationWillEnterForeground(_ application: UIApplication) { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | func applicationDidBecomeActive(_ application: UIApplication) { 41 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 42 | } 43 | 44 | func applicationWillTerminate(_ application: UIApplication) { 45 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 46 | } 47 | 48 | 49 | } 50 | 51 | -------------------------------------------------------------------------------- /YYUITextView/YYUITextView/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /YYUITextView/YYUITextView/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /YYUITextView/YYUITextView/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /YYUITextView/YYUITextView/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /YYUITextView/YYUITextView/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // YYUITextView 4 | // 5 | // Created by Domo on 2018/6/27. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController, UITextViewDelegate { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | self.navigationItem.title = "UITextField小解" 16 | self.view.backgroundColor = UIColor.white 17 | let textView = UITextView(frame: CGRect(x:30, y:200, width:UIScreen.main.bounds.width-60, height:200)) 18 | textView.delegate = self 19 | self.view.addSubview(textView) 20 | 21 | //属性设置 22 | //字体颜色 23 | textView.textColor = UIColor.purple 24 | //内容部分链接样式 25 | textView.linkTextAttributes = [NSAttributedStringKey.foregroundColor.rawValue: UIColor.orange, 26 | NSAttributedStringKey.underlineStyle.rawValue: NSUnderlineStyle.styleSingle.rawValue] 27 | //边框 28 | textView.layer.borderColor = UIColor.red.cgColor 29 | textView.layer.borderWidth = 1.5 30 | //字体大小 31 | textView.font = UIFont.systemFont(ofSize: 16) 32 | //内容可编辑 33 | textView.isEditable = false 34 | //内容可选 35 | textView.isSelectable = true 36 | //边框圆角设置 37 | textView.layer.masksToBounds = true 38 | textView.layer.cornerRadius = 5.0 39 | //自适应高度 40 | textView.autoresizingMask = UIViewAutoresizing.flexibleHeight 41 | 42 | 43 | //设置富文本 44 | let attributeString:NSMutableAttributedString=NSMutableAttributedString(string: "这是一条测试textview的字符串数据,欢迎访问 http://www.baidu.com") 45 | //设置字体颜色 46 | attributeString.addAttribute(NSAttributedStringKey.foregroundColor, value: UIColor.green, range: NSMakeRange(0, attributeString.length)) 47 | //文本所有字符字体HelveticaNeue-Bold,16号 48 | attributeString.addAttribute(NSAttributedStringKey.font, value: UIFont(name: "HelveticaNeue-Bold", size: 16)!, range: NSMakeRange(0, attributeString.length)) 49 | //文本0开始5个字符字体HelveticaNeue-Bold,16号 50 | attributeString.addAttribute(NSAttributedStringKey.font, value: UIFont(name: "HelveticaNeue-Bold", size: 26)!, range: NSMakeRange(0, 5)) 51 | //设置字体颜色 52 | attributeString.addAttribute(NSAttributedStringKey.foregroundColor, value: UIColor.white, range: NSMakeRange(0, 3)) 53 | //设置文字背景颜色 54 | attributeString.addAttribute(NSAttributedStringKey.backgroundColor, value: UIColor.orange, range: NSMakeRange(3, 3)) 55 | //赋值富文本 56 | textView.attributedText = attributeString 57 | 58 | 59 | //内容对齐方式 60 | textView.textAlignment = NSTextAlignment.center 61 | /* 62 | textView.textAlignment = NSTextAlignment.left 63 | textView.textAlignment = NSTextAlignment.center 64 | */ 65 | //给文中的特殊部分加上链接,比如手机号,网址邮箱等(需要注意的是如果使用了给特殊部分加上连接要先使内容不可编辑textView.isEditable = false) 66 | textView.dataDetectorTypes = UIDataDetectorTypes.link 67 | /* 68 | textView.dataDetectorTypes = UIDataDetectorTypes.link 69 | textView.dataDetectorTypes = UIDataDetectorTypes.address 70 | textView.dataDetectorTypes = UIDataDetectorTypes.calendarEvent 71 | textView.dataDetectorTypes = UIDataDetectorTypes.shipmentTrackingNumber 72 | textView.dataDetectorTypes = UIDataDetectorTypes.flightNumber 73 | textView.dataDetectorTypes = UIDataDetectorTypes.lookupSuggestion 74 | textView.dataDetectorTypes = UIDataDetectorTypes.phoneNumber 75 | */ 76 | // 键盘类型 77 | textView.keyboardType = UIKeyboardType.asciiCapable 78 | /* 79 | textView.keyboardType = UIKeyboardType.default 80 | textView.keyboardType = UIKeyboardType.numbersAndPunctuation 81 | textView.keyboardType = UIKeyboardType.URL 82 | textView.keyboardType = UIKeyboardType.numberPad 83 | textView.keyboardType = UIKeyboardType.phonePad 84 | textView.keyboardType = UIKeyboardType.namePhonePad 85 | textView.keyboardType = UIKeyboardType.emailAddress 86 | textView.keyboardType = UIKeyboardType.decimalPad 87 | textView.keyboardType = UIKeyboardType.twitter 88 | */ 89 | // 键盘返回类型 90 | textView.returnKeyType = UIReturnKeyType.continue 91 | /* 92 | textView.returnKeyType = UIReturnKeyType.default 93 | textView.returnKeyType = UIReturnKeyType.go 94 | textView.returnKeyType = UIReturnKeyType.google 95 | textView.returnKeyType = UIReturnKeyType.join 96 | textView.returnKeyType = UIReturnKeyType.next 97 | textView.returnKeyType = UIReturnKeyType.route 98 | textView.returnKeyType = UIReturnKeyType.search 99 | textView.returnKeyType = UIReturnKeyType.send 100 | textView.returnKeyType = UIReturnKeyType.yahoo 101 | textView.returnKeyType = UIReturnKeyType.done 102 | textView.returnKeyType = UIReturnKeyType.emergencyCall 103 | textView.returnKeyType = UIReturnKeyType.continue 104 | */ 105 | 106 | // 107 | let mail = UIMenuItem(title: "邮件", action: #selector(ViewController.onMail)) 108 | let weixin = UIMenuItem(title: "微信", action: #selector(ViewController.onWeiXin)) 109 | let menu = UIMenuController() 110 | menu.menuItems = [mail,weixin] 111 | } 112 | 113 | @objc func onMail(){ 114 | 115 | } 116 | 117 | @objc func onWeiXin(){ 118 | 119 | } 120 | // 开始编辑文本的时候触发该方法 121 | func textViewDidBeginEditing(_ textView: UITextView) { 122 | 123 | } 124 | // 结束编辑的时候触发该方法 125 | func textViewDidEndEditing(_ textView: UITextView) { 126 | 127 | } 128 | 129 | //如果返回false,文本视图不能编辑 130 | func textViewShouldBeginEditing(_ textView: UITextView) -> Bool { 131 | return true 132 | } 133 | 134 | //如果返回false,表示编辑结束之后,文本视图不可再编辑 135 | func textViewShouldEndEditing(_ textView: UITextView) -> Bool { 136 | return true 137 | } 138 | 139 | //文本视图内容改变时,触发本方法,如果是回车符号,则textView释放第一响应值,返回false 140 | func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { 141 | if (text == "\n") { 142 | textView.resignFirstResponder() 143 | return false; 144 | } 145 | return true 146 | } 147 | 148 | //文本视图改变后触发本代理方法 149 | func textViewDidChange(_ textView: UITextView) { 150 | 151 | } 152 | //文本视图 改变选择内容,触发本代理方法 153 | func textViewDidChangeSelection(_ textView: UITextView) { 154 | 155 | } 156 | //链接在文本中显示。当链接被点击的时候,会触发本代理方法 157 | func textView(_ textView: UITextView, shouldInteractWithURL: URL, in characterRange: NSRange) -> Bool{ 158 | return true 159 | } 160 | //文本视图允许提供文本附件,文本附件点击时,会触发本代理方法 return true 161 | func textView(_ textView: UITextView, shouldInteractWith textAttachment: NSTextAttachment, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool { 162 | return true 163 | } 164 | 165 | override func didReceiveMemoryWarning() { 166 | super.didReceiveMemoryWarning() 167 | // Dispose of any resources that can be recreated. 168 | } 169 | 170 | 171 | } 172 | 173 | -------------------------------------------------------------------------------- /YYUITextView/YYUITextViewTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /YYUITextView/YYUITextViewTests/YYUITextViewTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YYUITextViewTests.swift 3 | // YYUITextViewTests 4 | // 5 | // Created by Domo on 2018/6/27. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import YYUITextView 11 | 12 | class YYUITextViewTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /YYUITextView/YYUITextViewUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /YYUITextView/YYUITextViewUITests/YYUITextViewUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YYUITextViewUITests.swift 3 | // YYUITextViewUITests 4 | // 5 | // Created by Domo on 2018/6/27. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class YYUITextViewUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | // Use recording to get started writing UI tests. 33 | // Use XCTAssert and related functions to verify your tests produce the correct results. 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /YYUITextView/屏幕快照 2018-06-27 上午10.48.02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daomoer/YYSwiftLearnDemos/1fc858e6dbb0949b91fb17d7c8fecfaaadb8c7a6/YYUITextView/屏幕快照 2018-06-27 上午10.48.02.png -------------------------------------------------------------------------------- /YYWKWebView/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daomoer/YYSwiftLearnDemos/1fc858e6dbb0949b91fb17d7c8fecfaaadb8c7a6/YYWKWebView/.DS_Store -------------------------------------------------------------------------------- /YYWKWebView/YYWKWebView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | CF483D2820E4D7A0001A50EE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF483D2720E4D7A0001A50EE /* AppDelegate.swift */; }; 11 | CF483D2A20E4D7A0001A50EE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF483D2920E4D7A0001A50EE /* ViewController.swift */; }; 12 | CF483D2D20E4D7A0001A50EE /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CF483D2B20E4D7A0001A50EE /* Main.storyboard */; }; 13 | CF483D2F20E4D7A0001A50EE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CF483D2E20E4D7A0001A50EE /* Assets.xcassets */; }; 14 | CF483D3220E4D7A0001A50EE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CF483D3020E4D7A0001A50EE /* LaunchScreen.storyboard */; }; 15 | CF483D3D20E4D7A0001A50EE /* YYWKWebViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF483D3C20E4D7A0001A50EE /* YYWKWebViewTests.swift */; }; 16 | CF483D4820E4D7A0001A50EE /* YYWKWebViewUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF483D4720E4D7A0001A50EE /* YYWKWebViewUITests.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | CF483D3920E4D7A0001A50EE /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = CF483D1C20E4D7A0001A50EE /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = CF483D2320E4D7A0001A50EE; 25 | remoteInfo = YYWKWebView; 26 | }; 27 | CF483D4420E4D7A0001A50EE /* PBXContainerItemProxy */ = { 28 | isa = PBXContainerItemProxy; 29 | containerPortal = CF483D1C20E4D7A0001A50EE /* Project object */; 30 | proxyType = 1; 31 | remoteGlobalIDString = CF483D2320E4D7A0001A50EE; 32 | remoteInfo = YYWKWebView; 33 | }; 34 | /* End PBXContainerItemProxy section */ 35 | 36 | /* Begin PBXFileReference section */ 37 | CF483D2420E4D7A0001A50EE /* YYWKWebView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YYWKWebView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | CF483D2720E4D7A0001A50EE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 39 | CF483D2920E4D7A0001A50EE /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 40 | CF483D2C20E4D7A0001A50EE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 41 | CF483D2E20E4D7A0001A50EE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 42 | CF483D3120E4D7A0001A50EE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 43 | CF483D3320E4D7A0001A50EE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | CF483D3820E4D7A0001A50EE /* YYWKWebViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = YYWKWebViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | CF483D3C20E4D7A0001A50EE /* YYWKWebViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YYWKWebViewTests.swift; sourceTree = ""; }; 46 | CF483D3E20E4D7A0001A50EE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 47 | CF483D4320E4D7A0001A50EE /* YYWKWebViewUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = YYWKWebViewUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 48 | CF483D4720E4D7A0001A50EE /* YYWKWebViewUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YYWKWebViewUITests.swift; sourceTree = ""; }; 49 | CF483D4920E4D7A0001A50EE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50 | /* End PBXFileReference section */ 51 | 52 | /* Begin PBXFrameworksBuildPhase section */ 53 | CF483D2120E4D7A0001A50EE /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | ); 58 | runOnlyForDeploymentPostprocessing = 0; 59 | }; 60 | CF483D3520E4D7A0001A50EE /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | CF483D4020E4D7A0001A50EE /* Frameworks */ = { 68 | isa = PBXFrameworksBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | ); 72 | runOnlyForDeploymentPostprocessing = 0; 73 | }; 74 | /* End PBXFrameworksBuildPhase section */ 75 | 76 | /* Begin PBXGroup section */ 77 | CF483D1B20E4D7A0001A50EE = { 78 | isa = PBXGroup; 79 | children = ( 80 | CF483D2620E4D7A0001A50EE /* YYWKWebView */, 81 | CF483D3B20E4D7A0001A50EE /* YYWKWebViewTests */, 82 | CF483D4620E4D7A0001A50EE /* YYWKWebViewUITests */, 83 | CF483D2520E4D7A0001A50EE /* Products */, 84 | ); 85 | sourceTree = ""; 86 | }; 87 | CF483D2520E4D7A0001A50EE /* Products */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | CF483D2420E4D7A0001A50EE /* YYWKWebView.app */, 91 | CF483D3820E4D7A0001A50EE /* YYWKWebViewTests.xctest */, 92 | CF483D4320E4D7A0001A50EE /* YYWKWebViewUITests.xctest */, 93 | ); 94 | name = Products; 95 | sourceTree = ""; 96 | }; 97 | CF483D2620E4D7A0001A50EE /* YYWKWebView */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | CF483D2720E4D7A0001A50EE /* AppDelegate.swift */, 101 | CF483D2920E4D7A0001A50EE /* ViewController.swift */, 102 | CF483D2B20E4D7A0001A50EE /* Main.storyboard */, 103 | CF483D2E20E4D7A0001A50EE /* Assets.xcassets */, 104 | CF483D3020E4D7A0001A50EE /* LaunchScreen.storyboard */, 105 | CF483D3320E4D7A0001A50EE /* Info.plist */, 106 | ); 107 | path = YYWKWebView; 108 | sourceTree = ""; 109 | }; 110 | CF483D3B20E4D7A0001A50EE /* YYWKWebViewTests */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | CF483D3C20E4D7A0001A50EE /* YYWKWebViewTests.swift */, 114 | CF483D3E20E4D7A0001A50EE /* Info.plist */, 115 | ); 116 | path = YYWKWebViewTests; 117 | sourceTree = ""; 118 | }; 119 | CF483D4620E4D7A0001A50EE /* YYWKWebViewUITests */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | CF483D4720E4D7A0001A50EE /* YYWKWebViewUITests.swift */, 123 | CF483D4920E4D7A0001A50EE /* Info.plist */, 124 | ); 125 | path = YYWKWebViewUITests; 126 | sourceTree = ""; 127 | }; 128 | /* End PBXGroup section */ 129 | 130 | /* Begin PBXNativeTarget section */ 131 | CF483D2320E4D7A0001A50EE /* YYWKWebView */ = { 132 | isa = PBXNativeTarget; 133 | buildConfigurationList = CF483D4C20E4D7A0001A50EE /* Build configuration list for PBXNativeTarget "YYWKWebView" */; 134 | buildPhases = ( 135 | CF483D2020E4D7A0001A50EE /* Sources */, 136 | CF483D2120E4D7A0001A50EE /* Frameworks */, 137 | CF483D2220E4D7A0001A50EE /* Resources */, 138 | ); 139 | buildRules = ( 140 | ); 141 | dependencies = ( 142 | ); 143 | name = YYWKWebView; 144 | productName = YYWKWebView; 145 | productReference = CF483D2420E4D7A0001A50EE /* YYWKWebView.app */; 146 | productType = "com.apple.product-type.application"; 147 | }; 148 | CF483D3720E4D7A0001A50EE /* YYWKWebViewTests */ = { 149 | isa = PBXNativeTarget; 150 | buildConfigurationList = CF483D4F20E4D7A0001A50EE /* Build configuration list for PBXNativeTarget "YYWKWebViewTests" */; 151 | buildPhases = ( 152 | CF483D3420E4D7A0001A50EE /* Sources */, 153 | CF483D3520E4D7A0001A50EE /* Frameworks */, 154 | CF483D3620E4D7A0001A50EE /* Resources */, 155 | ); 156 | buildRules = ( 157 | ); 158 | dependencies = ( 159 | CF483D3A20E4D7A0001A50EE /* PBXTargetDependency */, 160 | ); 161 | name = YYWKWebViewTests; 162 | productName = YYWKWebViewTests; 163 | productReference = CF483D3820E4D7A0001A50EE /* YYWKWebViewTests.xctest */; 164 | productType = "com.apple.product-type.bundle.unit-test"; 165 | }; 166 | CF483D4220E4D7A0001A50EE /* YYWKWebViewUITests */ = { 167 | isa = PBXNativeTarget; 168 | buildConfigurationList = CF483D5220E4D7A0001A50EE /* Build configuration list for PBXNativeTarget "YYWKWebViewUITests" */; 169 | buildPhases = ( 170 | CF483D3F20E4D7A0001A50EE /* Sources */, 171 | CF483D4020E4D7A0001A50EE /* Frameworks */, 172 | CF483D4120E4D7A0001A50EE /* Resources */, 173 | ); 174 | buildRules = ( 175 | ); 176 | dependencies = ( 177 | CF483D4520E4D7A0001A50EE /* PBXTargetDependency */, 178 | ); 179 | name = YYWKWebViewUITests; 180 | productName = YYWKWebViewUITests; 181 | productReference = CF483D4320E4D7A0001A50EE /* YYWKWebViewUITests.xctest */; 182 | productType = "com.apple.product-type.bundle.ui-testing"; 183 | }; 184 | /* End PBXNativeTarget section */ 185 | 186 | /* Begin PBXProject section */ 187 | CF483D1C20E4D7A0001A50EE /* Project object */ = { 188 | isa = PBXProject; 189 | attributes = { 190 | LastSwiftUpdateCheck = 0920; 191 | LastUpgradeCheck = 0920; 192 | ORGANIZATIONNAME = "知言网络"; 193 | TargetAttributes = { 194 | CF483D2320E4D7A0001A50EE = { 195 | CreatedOnToolsVersion = 9.2; 196 | ProvisioningStyle = Automatic; 197 | }; 198 | CF483D3720E4D7A0001A50EE = { 199 | CreatedOnToolsVersion = 9.2; 200 | ProvisioningStyle = Automatic; 201 | TestTargetID = CF483D2320E4D7A0001A50EE; 202 | }; 203 | CF483D4220E4D7A0001A50EE = { 204 | CreatedOnToolsVersion = 9.2; 205 | ProvisioningStyle = Automatic; 206 | TestTargetID = CF483D2320E4D7A0001A50EE; 207 | }; 208 | }; 209 | }; 210 | buildConfigurationList = CF483D1F20E4D7A0001A50EE /* Build configuration list for PBXProject "YYWKWebView" */; 211 | compatibilityVersion = "Xcode 8.0"; 212 | developmentRegion = en; 213 | hasScannedForEncodings = 0; 214 | knownRegions = ( 215 | en, 216 | Base, 217 | ); 218 | mainGroup = CF483D1B20E4D7A0001A50EE; 219 | productRefGroup = CF483D2520E4D7A0001A50EE /* Products */; 220 | projectDirPath = ""; 221 | projectRoot = ""; 222 | targets = ( 223 | CF483D2320E4D7A0001A50EE /* YYWKWebView */, 224 | CF483D3720E4D7A0001A50EE /* YYWKWebViewTests */, 225 | CF483D4220E4D7A0001A50EE /* YYWKWebViewUITests */, 226 | ); 227 | }; 228 | /* End PBXProject section */ 229 | 230 | /* Begin PBXResourcesBuildPhase section */ 231 | CF483D2220E4D7A0001A50EE /* Resources */ = { 232 | isa = PBXResourcesBuildPhase; 233 | buildActionMask = 2147483647; 234 | files = ( 235 | CF483D3220E4D7A0001A50EE /* LaunchScreen.storyboard in Resources */, 236 | CF483D2F20E4D7A0001A50EE /* Assets.xcassets in Resources */, 237 | CF483D2D20E4D7A0001A50EE /* Main.storyboard in Resources */, 238 | ); 239 | runOnlyForDeploymentPostprocessing = 0; 240 | }; 241 | CF483D3620E4D7A0001A50EE /* Resources */ = { 242 | isa = PBXResourcesBuildPhase; 243 | buildActionMask = 2147483647; 244 | files = ( 245 | ); 246 | runOnlyForDeploymentPostprocessing = 0; 247 | }; 248 | CF483D4120E4D7A0001A50EE /* Resources */ = { 249 | isa = PBXResourcesBuildPhase; 250 | buildActionMask = 2147483647; 251 | files = ( 252 | ); 253 | runOnlyForDeploymentPostprocessing = 0; 254 | }; 255 | /* End PBXResourcesBuildPhase section */ 256 | 257 | /* Begin PBXSourcesBuildPhase section */ 258 | CF483D2020E4D7A0001A50EE /* Sources */ = { 259 | isa = PBXSourcesBuildPhase; 260 | buildActionMask = 2147483647; 261 | files = ( 262 | CF483D2A20E4D7A0001A50EE /* ViewController.swift in Sources */, 263 | CF483D2820E4D7A0001A50EE /* AppDelegate.swift in Sources */, 264 | ); 265 | runOnlyForDeploymentPostprocessing = 0; 266 | }; 267 | CF483D3420E4D7A0001A50EE /* Sources */ = { 268 | isa = PBXSourcesBuildPhase; 269 | buildActionMask = 2147483647; 270 | files = ( 271 | CF483D3D20E4D7A0001A50EE /* YYWKWebViewTests.swift in Sources */, 272 | ); 273 | runOnlyForDeploymentPostprocessing = 0; 274 | }; 275 | CF483D3F20E4D7A0001A50EE /* Sources */ = { 276 | isa = PBXSourcesBuildPhase; 277 | buildActionMask = 2147483647; 278 | files = ( 279 | CF483D4820E4D7A0001A50EE /* YYWKWebViewUITests.swift in Sources */, 280 | ); 281 | runOnlyForDeploymentPostprocessing = 0; 282 | }; 283 | /* End PBXSourcesBuildPhase section */ 284 | 285 | /* Begin PBXTargetDependency section */ 286 | CF483D3A20E4D7A0001A50EE /* PBXTargetDependency */ = { 287 | isa = PBXTargetDependency; 288 | target = CF483D2320E4D7A0001A50EE /* YYWKWebView */; 289 | targetProxy = CF483D3920E4D7A0001A50EE /* PBXContainerItemProxy */; 290 | }; 291 | CF483D4520E4D7A0001A50EE /* PBXTargetDependency */ = { 292 | isa = PBXTargetDependency; 293 | target = CF483D2320E4D7A0001A50EE /* YYWKWebView */; 294 | targetProxy = CF483D4420E4D7A0001A50EE /* PBXContainerItemProxy */; 295 | }; 296 | /* End PBXTargetDependency section */ 297 | 298 | /* Begin PBXVariantGroup section */ 299 | CF483D2B20E4D7A0001A50EE /* Main.storyboard */ = { 300 | isa = PBXVariantGroup; 301 | children = ( 302 | CF483D2C20E4D7A0001A50EE /* Base */, 303 | ); 304 | name = Main.storyboard; 305 | sourceTree = ""; 306 | }; 307 | CF483D3020E4D7A0001A50EE /* LaunchScreen.storyboard */ = { 308 | isa = PBXVariantGroup; 309 | children = ( 310 | CF483D3120E4D7A0001A50EE /* Base */, 311 | ); 312 | name = LaunchScreen.storyboard; 313 | sourceTree = ""; 314 | }; 315 | /* End PBXVariantGroup section */ 316 | 317 | /* Begin XCBuildConfiguration section */ 318 | CF483D4A20E4D7A0001A50EE /* Debug */ = { 319 | isa = XCBuildConfiguration; 320 | buildSettings = { 321 | ALWAYS_SEARCH_USER_PATHS = NO; 322 | CLANG_ANALYZER_NONNULL = YES; 323 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 324 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 325 | CLANG_CXX_LIBRARY = "libc++"; 326 | CLANG_ENABLE_MODULES = YES; 327 | CLANG_ENABLE_OBJC_ARC = YES; 328 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 329 | CLANG_WARN_BOOL_CONVERSION = YES; 330 | CLANG_WARN_COMMA = YES; 331 | CLANG_WARN_CONSTANT_CONVERSION = YES; 332 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 333 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 334 | CLANG_WARN_EMPTY_BODY = YES; 335 | CLANG_WARN_ENUM_CONVERSION = YES; 336 | CLANG_WARN_INFINITE_RECURSION = YES; 337 | CLANG_WARN_INT_CONVERSION = YES; 338 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 339 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 340 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 341 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 342 | CLANG_WARN_STRICT_PROTOTYPES = YES; 343 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 344 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 345 | CLANG_WARN_UNREACHABLE_CODE = YES; 346 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 347 | CODE_SIGN_IDENTITY = "iPhone Developer"; 348 | COPY_PHASE_STRIP = NO; 349 | DEBUG_INFORMATION_FORMAT = dwarf; 350 | ENABLE_STRICT_OBJC_MSGSEND = YES; 351 | ENABLE_TESTABILITY = YES; 352 | GCC_C_LANGUAGE_STANDARD = gnu11; 353 | GCC_DYNAMIC_NO_PIC = NO; 354 | GCC_NO_COMMON_BLOCKS = YES; 355 | GCC_OPTIMIZATION_LEVEL = 0; 356 | GCC_PREPROCESSOR_DEFINITIONS = ( 357 | "DEBUG=1", 358 | "$(inherited)", 359 | ); 360 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 361 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 362 | GCC_WARN_UNDECLARED_SELECTOR = YES; 363 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 364 | GCC_WARN_UNUSED_FUNCTION = YES; 365 | GCC_WARN_UNUSED_VARIABLE = YES; 366 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 367 | MTL_ENABLE_DEBUG_INFO = YES; 368 | ONLY_ACTIVE_ARCH = YES; 369 | SDKROOT = iphoneos; 370 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 371 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 372 | }; 373 | name = Debug; 374 | }; 375 | CF483D4B20E4D7A0001A50EE /* Release */ = { 376 | isa = XCBuildConfiguration; 377 | buildSettings = { 378 | ALWAYS_SEARCH_USER_PATHS = NO; 379 | CLANG_ANALYZER_NONNULL = YES; 380 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 381 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 382 | CLANG_CXX_LIBRARY = "libc++"; 383 | CLANG_ENABLE_MODULES = YES; 384 | CLANG_ENABLE_OBJC_ARC = YES; 385 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 386 | CLANG_WARN_BOOL_CONVERSION = YES; 387 | CLANG_WARN_COMMA = YES; 388 | CLANG_WARN_CONSTANT_CONVERSION = YES; 389 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 390 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 391 | CLANG_WARN_EMPTY_BODY = YES; 392 | CLANG_WARN_ENUM_CONVERSION = YES; 393 | CLANG_WARN_INFINITE_RECURSION = YES; 394 | CLANG_WARN_INT_CONVERSION = YES; 395 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 396 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 397 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 398 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 399 | CLANG_WARN_STRICT_PROTOTYPES = YES; 400 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 401 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 402 | CLANG_WARN_UNREACHABLE_CODE = YES; 403 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 404 | CODE_SIGN_IDENTITY = "iPhone Developer"; 405 | COPY_PHASE_STRIP = NO; 406 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 407 | ENABLE_NS_ASSERTIONS = NO; 408 | ENABLE_STRICT_OBJC_MSGSEND = YES; 409 | GCC_C_LANGUAGE_STANDARD = gnu11; 410 | GCC_NO_COMMON_BLOCKS = YES; 411 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 412 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 413 | GCC_WARN_UNDECLARED_SELECTOR = YES; 414 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 415 | GCC_WARN_UNUSED_FUNCTION = YES; 416 | GCC_WARN_UNUSED_VARIABLE = YES; 417 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 418 | MTL_ENABLE_DEBUG_INFO = NO; 419 | SDKROOT = iphoneos; 420 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 421 | VALIDATE_PRODUCT = YES; 422 | }; 423 | name = Release; 424 | }; 425 | CF483D4D20E4D7A0001A50EE /* Debug */ = { 426 | isa = XCBuildConfiguration; 427 | buildSettings = { 428 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 429 | CODE_SIGN_STYLE = Automatic; 430 | INFOPLIST_FILE = YYWKWebView/Info.plist; 431 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 432 | PRODUCT_BUNDLE_IDENTIFIER = com.zhiyan.YYWKWebView; 433 | PRODUCT_NAME = "$(TARGET_NAME)"; 434 | SWIFT_VERSION = 4.0; 435 | TARGETED_DEVICE_FAMILY = "1,2"; 436 | }; 437 | name = Debug; 438 | }; 439 | CF483D4E20E4D7A0001A50EE /* Release */ = { 440 | isa = XCBuildConfiguration; 441 | buildSettings = { 442 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 443 | CODE_SIGN_STYLE = Automatic; 444 | INFOPLIST_FILE = YYWKWebView/Info.plist; 445 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 446 | PRODUCT_BUNDLE_IDENTIFIER = com.zhiyan.YYWKWebView; 447 | PRODUCT_NAME = "$(TARGET_NAME)"; 448 | SWIFT_VERSION = 4.0; 449 | TARGETED_DEVICE_FAMILY = "1,2"; 450 | }; 451 | name = Release; 452 | }; 453 | CF483D5020E4D7A0001A50EE /* Debug */ = { 454 | isa = XCBuildConfiguration; 455 | buildSettings = { 456 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 457 | BUNDLE_LOADER = "$(TEST_HOST)"; 458 | CODE_SIGN_STYLE = Automatic; 459 | INFOPLIST_FILE = YYWKWebViewTests/Info.plist; 460 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 461 | PRODUCT_BUNDLE_IDENTIFIER = com.zhiyan.YYWKWebViewTests; 462 | PRODUCT_NAME = "$(TARGET_NAME)"; 463 | SWIFT_VERSION = 4.0; 464 | TARGETED_DEVICE_FAMILY = "1,2"; 465 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/YYWKWebView.app/YYWKWebView"; 466 | }; 467 | name = Debug; 468 | }; 469 | CF483D5120E4D7A0001A50EE /* Release */ = { 470 | isa = XCBuildConfiguration; 471 | buildSettings = { 472 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 473 | BUNDLE_LOADER = "$(TEST_HOST)"; 474 | CODE_SIGN_STYLE = Automatic; 475 | INFOPLIST_FILE = YYWKWebViewTests/Info.plist; 476 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 477 | PRODUCT_BUNDLE_IDENTIFIER = com.zhiyan.YYWKWebViewTests; 478 | PRODUCT_NAME = "$(TARGET_NAME)"; 479 | SWIFT_VERSION = 4.0; 480 | TARGETED_DEVICE_FAMILY = "1,2"; 481 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/YYWKWebView.app/YYWKWebView"; 482 | }; 483 | name = Release; 484 | }; 485 | CF483D5320E4D7A0001A50EE /* Debug */ = { 486 | isa = XCBuildConfiguration; 487 | buildSettings = { 488 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 489 | CODE_SIGN_STYLE = Automatic; 490 | INFOPLIST_FILE = YYWKWebViewUITests/Info.plist; 491 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 492 | PRODUCT_BUNDLE_IDENTIFIER = com.zhiyan.YYWKWebViewUITests; 493 | PRODUCT_NAME = "$(TARGET_NAME)"; 494 | SWIFT_VERSION = 4.0; 495 | TARGETED_DEVICE_FAMILY = "1,2"; 496 | TEST_TARGET_NAME = YYWKWebView; 497 | }; 498 | name = Debug; 499 | }; 500 | CF483D5420E4D7A0001A50EE /* Release */ = { 501 | isa = XCBuildConfiguration; 502 | buildSettings = { 503 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 504 | CODE_SIGN_STYLE = Automatic; 505 | INFOPLIST_FILE = YYWKWebViewUITests/Info.plist; 506 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 507 | PRODUCT_BUNDLE_IDENTIFIER = com.zhiyan.YYWKWebViewUITests; 508 | PRODUCT_NAME = "$(TARGET_NAME)"; 509 | SWIFT_VERSION = 4.0; 510 | TARGETED_DEVICE_FAMILY = "1,2"; 511 | TEST_TARGET_NAME = YYWKWebView; 512 | }; 513 | name = Release; 514 | }; 515 | /* End XCBuildConfiguration section */ 516 | 517 | /* Begin XCConfigurationList section */ 518 | CF483D1F20E4D7A0001A50EE /* Build configuration list for PBXProject "YYWKWebView" */ = { 519 | isa = XCConfigurationList; 520 | buildConfigurations = ( 521 | CF483D4A20E4D7A0001A50EE /* Debug */, 522 | CF483D4B20E4D7A0001A50EE /* Release */, 523 | ); 524 | defaultConfigurationIsVisible = 0; 525 | defaultConfigurationName = Release; 526 | }; 527 | CF483D4C20E4D7A0001A50EE /* Build configuration list for PBXNativeTarget "YYWKWebView" */ = { 528 | isa = XCConfigurationList; 529 | buildConfigurations = ( 530 | CF483D4D20E4D7A0001A50EE /* Debug */, 531 | CF483D4E20E4D7A0001A50EE /* Release */, 532 | ); 533 | defaultConfigurationIsVisible = 0; 534 | defaultConfigurationName = Release; 535 | }; 536 | CF483D4F20E4D7A0001A50EE /* Build configuration list for PBXNativeTarget "YYWKWebViewTests" */ = { 537 | isa = XCConfigurationList; 538 | buildConfigurations = ( 539 | CF483D5020E4D7A0001A50EE /* Debug */, 540 | CF483D5120E4D7A0001A50EE /* Release */, 541 | ); 542 | defaultConfigurationIsVisible = 0; 543 | defaultConfigurationName = Release; 544 | }; 545 | CF483D5220E4D7A0001A50EE /* Build configuration list for PBXNativeTarget "YYWKWebViewUITests" */ = { 546 | isa = XCConfigurationList; 547 | buildConfigurations = ( 548 | CF483D5320E4D7A0001A50EE /* Debug */, 549 | CF483D5420E4D7A0001A50EE /* Release */, 550 | ); 551 | defaultConfigurationIsVisible = 0; 552 | defaultConfigurationName = Release; 553 | }; 554 | /* End XCConfigurationList section */ 555 | }; 556 | rootObject = CF483D1C20E4D7A0001A50EE /* Project object */; 557 | } 558 | -------------------------------------------------------------------------------- /YYWKWebView/YYWKWebView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /YYWKWebView/YYWKWebView/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // YYWKWebView 4 | // 5 | // Created by Domo on 2018/6/28. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | 19 | let rootVC = ViewController() 20 | let rootNav = UINavigationController.init(rootViewController: rootVC) 21 | self.window?.rootViewController = rootNav 22 | self.window?.makeKeyAndVisible() 23 | 24 | return true 25 | } 26 | 27 | func applicationWillResignActive(_ application: UIApplication) { 28 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 29 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 30 | } 31 | 32 | func applicationDidEnterBackground(_ application: UIApplication) { 33 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 35 | } 36 | 37 | func applicationWillEnterForeground(_ application: UIApplication) { 38 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 39 | } 40 | 41 | func applicationDidBecomeActive(_ application: UIApplication) { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | func applicationWillTerminate(_ application: UIApplication) { 46 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 47 | } 48 | 49 | 50 | } 51 | 52 | -------------------------------------------------------------------------------- /YYWKWebView/YYWKWebView/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /YYWKWebView/YYWKWebView/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /YYWKWebView/YYWKWebView/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /YYWKWebView/YYWKWebView/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /YYWKWebView/YYWKWebView/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // YYWKWebView 4 | // 5 | // Created by Domo on 2018/6/28. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import WebKit 11 | 12 | class ViewController: UIViewController ,WKUIDelegate, WKNavigationDelegate{ 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | self.navigationItem.title = "WKWebView使用" 16 | self.view.backgroundColor = UIColor.white 17 | let webView = WKWebView(frame: self.view.bounds) 18 | webView.uiDelegate = self 19 | webView.navigationDelegate = self 20 | self.view.addSubview(webView) 21 | webView.load(URLRequest.init(url: URL.init(string: "https://www.baidu.com")!)) 22 | 23 | // 属性设置 24 | 25 | } 26 | 27 | // 处理在接收到响应之后决定是否进行跳转 28 | func webView(_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse, decisionHandler: @escaping (WKNavigationResponsePolicy) -> Void) { 29 | 30 | decisionHandler(.allow) 31 | } 32 | 33 | // 处理在发送请求之前决定是否进行跳转 34 | func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { 35 | 36 | decisionHandler(.allow) 37 | } 38 | 39 | // 网页开始加载时候调用该方法 40 | func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) { 41 | 42 | } 43 | // 网页加载失败使用该方法 44 | func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) { 45 | 46 | } 47 | // 网页内容开始返回该方法 48 | func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) { 49 | 50 | } 51 | // 收到服务器跳转请求之后调用 52 | func webView(_ webView: WKWebView, didReceiveServerRedirectForProvisionalNavigation navigation: WKNavigation!) { 53 | 54 | } 55 | 56 | // 网页加载完成调用该方法 57 | func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { 58 | 59 | } 60 | // 网页返回内容时失败调用该方法 61 | func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) { 62 | 63 | } 64 | 65 | 66 | 67 | override func didReceiveMemoryWarning() { 68 | super.didReceiveMemoryWarning() 69 | // Dispose of any resources that can be recreated. 70 | } 71 | 72 | 73 | } 74 | 75 | -------------------------------------------------------------------------------- /YYWKWebView/YYWKWebViewTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /YYWKWebView/YYWKWebViewTests/YYWKWebViewTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YYWKWebViewTests.swift 3 | // YYWKWebViewTests 4 | // 5 | // Created by Domo on 2018/6/28. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import YYWKWebView 11 | 12 | class YYWKWebViewTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /YYWKWebView/YYWKWebViewUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /YYWKWebView/YYWKWebViewUITests/YYWKWebViewUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // YYWKWebViewUITests.swift 3 | // YYWKWebViewUITests 4 | // 5 | // Created by Domo on 2018/6/28. 6 | // Copyright © 2018年 知言网络. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class YYWKWebViewUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | // Use recording to get started writing UI tests. 33 | // Use XCTAssert and related functions to verify your tests produce the correct results. 34 | } 35 | 36 | } 37 | --------------------------------------------------------------------------------