|
With so much convenience woven into SwiftUI I was surprised there no means of controlling the corner radius to allow for the illusion of a seamless joining between a TextField and its respective submission Button.
Where the two elements touch the corners must be right angles, but the edges are not rounded. If there is an offical method I must have missed it, otherwise can anybody else have a go ? |
|
Not sure if this is what you're trying to achieve, but try this.
The only downside of the above code is that if your text is long, it will go behind the button. But you can slightly modify it so that it will separate text field and button like so.
|
|
Thank you, I quite like your second solution. I should have provided an image for reference, here you go: |
SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge. Sponsor Hacking with Swift and reach the world's largest Swift community! |
|
Identical approach can do the job
|
|
I was playing with
|
|
Thanks for the effort guys, but it seems that UnevenRoundedRectangle is a custom shape, any info on this ? |
|
As they always say it check the documents UnevenRoundedRectangle. It a like RoundedRectangle but you can change any corner to be rounded. |
|
I have playing around a bit more to make it more reusable
And now you can use it
PS while the |
|
I know it's been a while but I had to learn SwiftUI and so I am a lot better able to manipulate things now. I am on iOS 15.2 here, so no UnevenRoundedRectangle for me. I tried to make one by layering shapes on the Z-axis:
The following will achieve something like what I need, but the effect is spoilt on a press event, as all the layers are visible when the button turns semi-transparent to signify that it has been pressed: |
|
The following code will allow for the buttons to be independently pressed:
|
|
Hi! Wouldn't it make your code do almost the same, not sure what is the function of your buttons... But less code and visibly result is the same, but no weird blinking...
|
SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.