Hi Im trying to achieve this result in the image of this Stack overflow questionhttps://stackoverflow.com/questions/56623310/swiftui-login-page-layoutAs you can see I already reached this point but I don't like my implementationstruct ContentView : View { @State var username: String = var body: some View { VStack(alignment: .leading) { Text(Login) .font(.title) .multilineTextAlignment(.center) .lineLimit(nil) Text(Please) .font(.subheadline) HStack { VStack (alignment: .leading, spacing: 20) { Text(Username: ) Text(Password: ) } VStack { TextField($username, placeholder: Text(type something here...)) .textFieldStyle(.roundedBorder) TextField($username, placeholder: Text(type something here...)) .textFieldStyle(.roundedBorder) } } }.padding() } }Because in order to make the username and password text aligned exactly in the middle of the textfield, I had to put literal spacing value of 20 in the VStack which I don't like because most probably It won't work on different device sizes.Anyone sees a bette
Search results for
swiftui
16,583 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
In UIKit we could do things like:func didTap(_ sender: AnyObject?) { guard let sender = sender as? UIView else { return } // use frame of sender to present a popup, etc... }Will anything similar be made available for SwiftUI? Some method of refering back to the frame of the View that initiates an event would seem very handy for popovers. `Popover` has `targetPoint` and `targetRect` but it's not clear how those can actually be determined during construction of the body when layout hasn't even occurred yet.
Digging around in the crash logs I found references to the Thread Sanitizer. So I turned it off and now I have this error:Points Master.app: Error Domain=com.apple.dt.UITestingAgent Code=-1 Preview provider 13Points_Master17MainView_PreviewsV does not exist UserInfo={NSLocalizedDescription=Preview provider 13Points_Master17MainView_PreviewsV does not exist}So I was thinking one step a head then I figured out my project didn't have the 'DEBUG' active compilation condition so the SwiftUI preview functions where not visible to Xcode.It's all now working.
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags:
I would like to know what is the sanctioned way to create the equivalent to a UISplitViewController on iPad using Swift UI to create what Xcode names master-detail apps.Thank you.
Thanks, and well spotted! I went over it line for line several times and never spotted that. Of course, now it's telling me their's no such module as 'SwiftUI'. It also doesn't like the opaque data type related 'some' keyword and I can't find any of the simulators to build against. I guess it's still very much in beta. :-/
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
Hi, there does seem to be something going on with beta 2, beta 1 installed fine (wanted to start looking at SwiftUI) but beta 2 starts the install, getts to [15 seconds Remaining] before announcing Could not create a preboot volume for APFS install I have tried rebooting, but keep hitting the same error. MacBook Pro 15-inch 2018, currently running 10.15 beta 1
I faced the same issue that the new systemColors are not available on swiftUI. Also defining colors for darkmode in asset catalog do not work.I ended up creating a custom swiftUI view that use UIColor instead of SwiftUI.Color.import SwiftUI struct BackgroundView : UIViewRepresentable { var color: UIColor = .systemBackground func makeUIView(context: Context) -> UIView { UIView(frame: .zero) } func updateUIView(_ view: UIView, context: Context) { view.backgroundColor = color } } #if DEBUG struct BackgroundView_Previews : PreviewProvider { static var previews: some View { BackgroundView(color: UIColor.systemBackground) } } #endifSince the .background modifier will take a swiftUI view you can simply use this BackgroundViewText(Some Text) .background(BackgroundView(color: .systemRed))
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
We're on the same boat... It seems it is not possible to select the keyboard. I also could not locate a way of making a TextField the firstResponder, so that it gets focus.As for the password fields, you can use SecureField, instead of TextField:https://developer.apple.com/documentation/swiftui/securefield
Topic:
App & System Services
SubTopic:
Core OS
Tags:
Hi all,I'm looking for a way to vertically scroll several grouped elements in a VStack. If I use List, it places everything in Table cells, (which I don't want). Wrapping everything in ScrollView, automatically expands all my VStacked elements beyond the screen width. Is there currently any way with ScrollView to respect the screen's width, and only scroll vertically?In a nutshell, I'm trying to mimic a one column UICollectionView. Not styled like a table, but smooth vertical-only scrolling.- Scott
I am trying to use SwiftUI for an iPad app and want to include a button (ellipsis) to access a menu.I have a Button, displaying the Image(systemName: ellipsis). I am trying to understand how to display a new View as a popover tied to the pressed button.To use Popover, I need a target point, but I don't see how to gain access to this under SwiftUI. Anyone have any clues on this?
At first I created a UIViewRepresentable to wrap a UITextField... and that works... There is, however, another option which takes advantage of the fact that it seems the SwiftUI TextField is actually already implemented as a UITextField. By observing the UITextField.textDidBeginEditingNotification I managed to change the keyboard. This is an ugly, ugly hack... that works. I leave it hear mostly for purely academic purposes... I don't think I would like to use this on production code:import SwiftUI let dirtyWork = DirtyWork() struct ContentView : View { @State private var emailAccount: String = @State private var twitterAccount: String = var body: some View { return VStack { TextField($emailAccount, onEditingChanged: { if $0 { dirtyWork.keyboardType = .emailAddress } }).textFieldStyle(.roundedBorder) TextField($twitterAccount, onEditingChanged: { if $0 { dirtyWork.keyboardType = .twitter } }).textFieldStyle(.roundedBorder) Spacer() } } } class DirtyWork { var keyboardType: UIKeyboardType =
Topic:
App & System Services
SubTopic:
Core OS
Tags:
With the new beta 2, the divider is resizable for me by default.I am trying to simulate an NSOutlineView by using a sidebar with nested sublists:struct ContentView : View { var body: some View { HSplitView() { List() { Section(header: Text(Section 1)) { Text(Sub 1.1) Text(Sub 1.2) } Section(header: Text(Section 2)) { Text(Sub 2.1) List { Section(header: Text(Subsection 2.2)) { Text(Sub 2.2.1) Text(Sub 2.2.2) } Section(header: Text(Subsection 2.3)) { Text(Sub 2.3.1) Text(Sub 2.3.2) } } //.frame(height: 140) } Section(header: Text(Section 3)) { Text(Sub 3.1) Text(Sub 3.2) } }.listStyle(.sidebar) List() { Text(Content) Text(Content) Text(Content) Text(Content) } } } }By uncommenting the 22nd line, you can see and un/fold the sections of the second sublist, otherwise SwiftUI assigns a fixed height to all the sections. I can't find a simple way to force the height of a section to the intrinsic height of its content.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
PresentationButton init has been altered for Xcode 11 Beta 2 to use a ViewBuilder - https://developer.apple.com/documentation/swiftui/presentationbutton/3326830-init?changes=latest_betaExamples listed in SwiftUI Tutorials Need UpdatingFrom: Working with UI Controls TutorialHome.swift - Beta 1 code.navigationBarItems(trailing: PresentationButton( Image(systemName: person.crop.circle) .imageScale(.large) .accessibility(label: Text(User Profile)) .padding(), destination: ProfileHost() ))Home.swift - Beta 2 code.navigationBarItems(trailing: PresentationButton( destination: ProfileHost(), label: { Image(systemName: person.crop.circle) .imageScale(.large) .accessibility(label: Text(User Profile)) .padding() } ))
Thanks for the reply.I can get enumerated() to work fine with normal for loops, the problem comes when I am trying to use it with SwiftUI's ForEach object (normal for loops don't work with SwiftUI yet)
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
hi,sorry that i didn't pick up right away on the subtlety here, of it having to do with SwiftUI code -- although it was posted in SwiftUI (duh!) and does mention something about a data source.on the Swift side, you can certainly do a forEach() instead of an explicit for loop:array.enumerated().forEach( { print($0.0,$0.1) } )this will give the same output as what i showed above. can't say where this leads in SwiftUI and a data source, since i haven't gotten to SwiftUI yet (but maybe next month!)good luck (and apologies for giving a simple answer to a question other than what was asked),DMGEDIT: the following code might be more clear for readability than what was above:array.enumerated().forEach( { (index,item) in print(index,item) } )
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: