This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // CustomSwipeActionsSwiftUI | |
| // | |
| // Custom Swipe Actions in Lists are provided by default, however even if you add a title and an icon to the SwipeAction, | |
| // SwiftUI will decide internally which one to you (or both). So you do not have full control on how your swipe action | |
| // button appears... I was implementing a custom swipe action and discovered many pitfalls in the List + SwipeActions | |
| // combination in SwiftUI. Checkout how I solved it with a dragGesture and views on a ScrollView. | |
| // It's a lot of craft to make these custom actions work, so I do not recommend to use such a fancy alternative unless | |
| // you have extremely good reasons since you will loose the capabilities offered by the system to do swipe, drags, | |
| // gestures interactions calculations on its own, and it will cost you on maintenance in the future. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| /// the biggest enum ever in my life :) | |
| /// All SFSymbols names in one enum | |
| enum SFSymbol: String, CaseIterable { | |
| case squareandarrowup = "square.and.arrow.up" | |
| case squareandarrowupfill = "square.and.arrow.up.fill" | |
| case squareandarrowupcircle = "square.and.arrow.up.circle" | |
| case squareandarrowupcirclefill = "square.and.arrow.up.circle.fill" | |
| case squareandarrowupbadgeclock = "square.and.arrow.up.badge.clock" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // example to show how to check if core data can infers a mapping model by itself | |
| // do not forget to add the .momd to you model object package!!!! | |
| // https://developer.apple.com/documentation/coredata/nsmappingmodel/1506468-inferredmappingmodelforsourcemod | |
| // SWIFT 4 | |
| if let previousModelURL = Bundle.main.url(forResource: "YOURMODELNAME.momd/YOURMODELVERSION 2", withExtension: "mom"), | |
| let previousModel = NSManagedObjectModel(contentsOf: previousModelURL), | |
| let currentModelURL = Bundle.main.url(forResource: "YOURMODELNAME.momd/YOURMODELVERSION 3", withExtension: "mom"), | |
| let currentModel = NSManagedObjectModel(contentsOf: currentModelURL) { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // CoreDataStackTheOldWay.swift | |
| // CoreDataShowcase | |
| // | |
| // Created by Barbara Rodeker on 24.09.17. | |
| // | |
| // THIS CLASS CONTAINS PROPERTIES THAT NEEDED TO BE | |
| // CREATED FOR CORE DATA BEFORE THE EXISTENCE OF NSPERSISTENTCONTAINER (added in iOS10) | |
| // | |
| // SWIFT 4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // CoreDataStack.swift | |
| // CoreDataShowcase | |
| // | |
| // Created by Barbara Rodeker on 31.10.17. | |
| // | |
| // THIS CLASS CONTAINS ALL THE REQUIRED PROPERTIES THAT NEED TO BE CREATED | |
| // FOR CORE DATA AFTER NSPersistentContainer was added in IOS 10 | |
| // | |
| // SWIFT 4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Create a persistent container with an specific description for the stores | |
| private(set) lazy var container: NSPersistentContainer = { | |
| let description = NSPersistentStoreDescription() | |
| description.type = NSSQLiteStoreType | |
| description.shouldInferMappingModelAutomatically = false | |
| description.shouldMigrateStoreAutomatically = true | |
| let container = NSPersistentContainer(name: CoreDataStackTheNewWay.modelName) | |
| container.persistentStoreDescriptions = [description] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| // Extension on PropertyListSerialization to read an array from a property list file | |
| extension PropertyListSerialization { | |
| // Takes the name of the PLIST file to be read. Name must be provided without extension. | |
| // returns an optional array if the file can be opened and parsed properly. | |
| // - Parameters: | |
| // - named String with the filename. No extension .plist needed | |
| static func arrayFromPlist(named name: String) -> [Any]? { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Model used -> https://free3d.com/download-page.php?url=rose-31675 | |
| let scene = SCNScene(named: "rose.obj") | |
| // Set up the SceneView | |
| sceneView.autoenablesDefaultLighting = true | |
| sceneView.allowsCameraControl = true | |
| sceneView.scene = scene | |
| sceneView.backgroundColor = .black |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let effectView = UIVisualEffectView() | |
| effectView.frame = view.bounds | |
| effectView.autoresizingMask = [.flexibleWidth, .flexibleHeight] | |
| view.addSubview(effectView) | |
| let e = UIBlurEffect(style: .dark) | |
| effectView.effect = e |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // iOS 10 working way to fade in a blurred view (changing alpha in the container does not work on iOS 10) | |
| let effectView = UIVisualEffectView() | |
| effectView.frame = toast.bounds | |
| effectView.autoresizingMask = [.flexibleWidth, .flexibleHeight] | |
| view.addSubview(effectView) //replace view with whatever view you want to blur | |
| UIView.animate(withDuration: 0.2) { | |
| let blur = UIBlurEffect(style: .light) | |
| effectView.effect = blur |
NewerOlder