Search results for

swiftui

16,583 results found

Post

Replies

Boosts

Views

Activity

SwiftUI Login Page Layout
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
1
0
2.6k
Jun ’19
Referencing size/location of child Views
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.
1
0
1.8k
Jun ’19
Reply to Xcode 11: SwiftUI preview not working
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.
Jun ’19
Reply to Drawing Paths and Shapes tutorial won't compile
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:
Jun ’19
macOS Cataline beta2 - APFS install error
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
6
0
2.1k
Jun ’19
Reply to New UI Element colors in SwiftUI
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:
Jun ’19
Reply to Keyboard type in SwiftUI
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:
Jun ’19
Unstyled, non looped, vertical scrolling in SwiftUI
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
1
0
849
Jun ’19
Popover and how to compute 'targetPoint'?
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?
0
0
645
Jun ’19
Reply to Keyboard type in SwiftUI
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:
Jun ’19
Reply to How to make a resizable HSplitView for macOS?
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:
Jun ’19
SwiftUI Tutorials Need Updating for PresentationButton in Beta 2
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() } ))
3
0
2.5k
Jun ’19
Reply to Getting the index in ForEach
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:
Jun ’19