Post

Replies

Boosts

Views

Activity

Reply to Conditional modifiers: if #available iOS 14
You can create a custom modifier to handle this, like so: @available(iOS 14, *) struct NavigationTitleViewModifier: ViewModifier { 	var text: String 	 	func body(content: Content) -> some View { 		content 			.navigationTitle(text) 	} } struct NavigationBarTitleViewModifier: ViewModifier { 	var text: String 	 	func body(content: Content) -> some View { 		content 			.navigationBarTitle(text) 	} } extension View { 	@ViewBuilder 	func customNavigationTitle(with text: String) -> some View { 		if #available(iOS 14, *) { 			self 				.modifier(NavigationTitleViewModifier(text: text)) 		} 		else { 			self.modifier(NavigationBarTitleViewModifier(text: text)) 		} 	} } Then, instead of having to write those conditionals every time you want to add a navigation title, you can simply do: SettingsContentView() 	.customNavigationTitle(with: "Settings")
Jul ’20
Reply to SwiftUI Compatibility on iOS 13
Everything that worked on iOS 13 will continue to work on iOS 14. You can take a look at the official release notes here - https://developer.apple.com/documentation/ios-ipados-release-notes/ios-ipados-14-beta-release-notes. There does not appear to be any deprecations under SwiftUI, so you should be good!
Jul ’20
Reply to DOMContentLoaded not working in Safari App Extension
Hey everyone! I have figured out a work-around to the issue. It appears that a lot of the time, the DOMContentLoaded event would fire before the event listener got called. This workaround worked for me: function runOnStart() { 		// Run your code here } if(document.readyState !== 'loading') {     runOnStart(); } else {     document.addEventListener('DOMContentLoaded', function () {         runOnStart()     }); } It checks to see if DOMContentLoaded has already been fired (hence the document is no longer loading), and if so, run the code. If it has not been fired yet, then the listener is initialized.
Jun ’20
Reply to Catalyst and Native using SwiftUI to develop a new app for the macOS?
Apple is really pushing for the development experience for macOS and iOS/iPadOS to be merged and made more seamless (hence the introduction of Catalyst. Plus, the transition to ARM chips will merge the development experience even more). Catalyst is a powerful technology that is able to meet a lot of requirements, and is a great choice considering the trend for cross-platform development that Apple is pushing for. However, there are still things missing. For example, HomeKit and ClassKit are being added in macOS Big Sur (Mac Catalyst 14). If you were looking to target older versions of Mac and still be able to use these technologies, then Catalyst is not the way to go. I would recommend looking here - https://developer.apple.com/documentation/technologies to ensure the technologies you want to use are compatible with the version you are targeting. Most of them are available since Mac Catalyst 13, but there are a few exceptions (such as HomeKit). That being said, if all of your technologies are available (or you are targeting Mac Catalyst 14+), then I don't think you can go wrong with using Catalyst. It is a very powerful tool, and is definitely the trend of development that Apple is currently pushing for.
Jun ’20
Reply to SwiftUI Version
The changes/additions to SwiftUI are only going to be available on iOS 14 and beyond. If you look at the list here - https://developer.apple.com/documentation/swiftui/views-and-controls, you can look for the items marked Beta, which are a part of the new SwiftUI additions and are only available on iOS 14 and beyond.
Jun ’20
Reply to Unable to create View extension; custom view modifiers
The issue you are having is due to the fact that you declare "AnimatableFontModifier" twice. You must change either the struct name or the func name. See below for an example of how to update the code: import SwiftUI struct AnimatableFontModifier: AnimatableModifier{   var fontSize: CGFloat   var animatableData: CGFloat{     get{       fontSize     }     set{       fontSize = newValue     }   }   func body(content: Content) -> some View {     content.font(Font.system(size: fontSize))   } } extension View {   func AnimatableFontModifierExtension(fontSize: CGFloat) -> some View{     self.modifier(AnimatableFontModifier(fontSize: fontSize))   } }
Jun ’20
Reply to How to set a background image for whole view (List) not rows
I was able to get this to work by altering the UITableView and UITableViewCell themselves. Here is the code: struct ListView: View {   var body: some View {     NavigationView {       List {         Text("Hello!")       }       .onAppear() {         UITableViewCell.appearance().backgroundColor = UIColor.clear                   let imageView = UIImageView(image: UIImage(named: "Dogs.jpeg"))         imageView.contentMode = .top         UITableView.appearance().backgroundView = imageView       }     }   } } The imageView.contentMode can be changed to a variety of other choices that best fit your needs, see here - https://developer.apple.com/documentation/uikit/uiview/contentmode. .top will place the image at the top of the list, without stretching it.
Jun ’20