Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Add input method
Source Link
Bbrk24
  • 3.9k
  • 26
  • 23

Swift, entire iOS app, 75152 bytes

project.pbxproj not included.

import SwiftUI
@main struct A:App{let@State body=WindowGroupvar s="1"
var body:some Scene{WindowGroup{VStack{TextField("",text:$s)
Circle().paddingframe(width:.init(Int(s)!))}}}}

PreviewThe unit for the radius is 0.5pt, which is either 1px or 1.5px depending on iPhone Xʀthe device. The app crashes if you type something that isn't an integer.

Preview, with a radius of 50pt:

11

Ungolfed

import SwiftUI
@main
struct MyApp: App {
 var body: some Scene {
 WindowGroup {
 ContentView()
 }
 }
}
struct ContentView: View {
 @State private var text = "1"

 var body: some View {
 VStack {
 TextField("", text: $text)

 Circle()
 .paddingframe(width: CGFloat(Int(text)!))
 }
 }
}

Swift, entire iOS app, 75 bytes

project.pbxproj not included.

import SwiftUI
@main struct A:App{let body=WindowGroup{Circle().padding()}}

Preview on iPhone Xʀ:

1

Ungolfed

import SwiftUI
@main
struct MyApp: App {
 var body: some Scene {
 WindowGroup {
 ContentView()
 }
 }
}
struct ContentView: View {
 var body: some View {
 Circle()
 .padding()
 }
}

Swift, entire iOS app, 152 bytes

project.pbxproj not included.

import SwiftUI
@main struct A:App{@State var s="1"
var body:some Scene{WindowGroup{VStack{TextField("",text:$s)
Circle().frame(width:.init(Int(s)!))}}}}

The unit for the radius is 0.5pt, which is either 1px or 1.5px depending on the device. The app crashes if you type something that isn't an integer.

Preview, with a radius of 50pt:

1

Ungolfed

import SwiftUI
@main
struct MyApp: App {
 var body: some Scene {
 WindowGroup {
 ContentView()
 }
 }
}
struct ContentView: View {
 @State private var text = "1"

 var body: some View {
 VStack {
 TextField("", text: $text)

 Circle()
 .frame(width: CGFloat(Int(text)!))
 }
 }
}
Source Link
Bbrk24
  • 3.9k
  • 26
  • 23

Swift, entire iOS app, 75 bytes

project.pbxproj not included.

import SwiftUI
@main struct A:App{let body=WindowGroup{Circle().padding()}}

Preview on iPhone Xʀ:

1

Ungolfed

import SwiftUI
@main
struct MyApp: App {
 var body: some Scene {
 WindowGroup {
 ContentView()
 }
 }
}
struct ContentView: View {
 var body: some View {
 Circle()
 .padding()
 }
}

AltStyle によって変換されたページ (->オリジナル) /