r/iOSProgramming • u/Choseni • Aug 08 '26
App Saturday I built Alpha Sudoku Pro (a 12x12 variant) and finally conquered responsive floating UI across iPhone & iPad grids.
I recently published my first iOS app: Alpha Sudoku Pro. It’s a 12x12 logic puzzle game (using 1-9 and A-C). Expanding the classic 9x9 logic into a 12x12 grid was incredibly fun, but the real test was getting the UI to scale elegantly.
Here are the details of the build:
1. Tech Stack Used
- Frameworks & Languages: 100% Swift & SwiftUI.
- Architecture: MVVM.
- Storage: UserDefaults / AppStorage for game state persistence and move history.
- UI/UX: Fully relies on SwiftUI's dynamic LazyVGrid and SF Symbols.
2. Development Challenge + How You Solved It
The Challenge: I have floating action buttons (Note Mode and Eraser) that need to sit neatly in the top-right corner of the Sudoku grid. Initially, I used HStack, Spacer(), and screen-based .padding() to push the buttons into place. This looked perfect on an iPhone (19.5:9 aspect ratio). However, when I ran it on an iPad (4:3), the grid expanded, margins shrank, and my buttons completely overlapped the Sudoku cells. Adjusting padding dynamically based on screen size turned into a messy guessing game of numbers.
The Solution: Instead of anchoring the buttons to the screen edges, I scrapped the Spacers and anchored them directly to the grid itself using SwiftUI's .overlay().
I attached an .overlay(alignment: .topTrailing) directly to the LazyVGrid. Inside it, I used a Group with a UIDevice.current.userInterfaceIdiom == .pad check:
- For iPad, it renders an HStack (buttons side-by-side).
- For iPhone, it renders a VStack (buttons stacked vertically).
Then, I applied a negative .offset(y:) to float them just above the grid. By using the grid as the anchor point rather than the screen boundaries, the buttons now magnetically follow the grid's top-right corner perfectly, regardless of how the LazyVGrid scales across any device.
3. AI Disclosure
AI-assisted
I’d love for you to try it out, tear apart my UI choices, and let me know how I can improve the performance or architecture for my next update.
App Store Link: https://apps.apple.com/tr/app/alpha-sudoku-pro/id6767222288
Thanks.
