Welcome to admaDIC's Development Site
SwiftUI Card Flip
A simple card flip animation can be implemented in SwiftUI quite easily. For the flip transformation the modifier `rotation3DEffect()` works nicely.
[more ...]Fonts and Bounds
With `NSAttributedString` one can calculate the bounding box of an attributed string when it is rendered. In the example a `UILabel` is used to show the `NSAttributedString` and a `Rectangle` with the size of the string's bounding box is layered under the label.
[more ...]SwiftUI ViewModifier
SwiftUI provides so called ViewModifiers. A ViewModifier is a reusable type that defines how to change or decorate a view's appearance or behavior.
[more ...]SwiftUI Custom Ring Progress View
A custom ring progress view with color gradient is implemented using `Circle()`, `.stroke` and `.trim`. Two circle paths are layered on top of each other to render the progress track and the actual progress ring.
[more ...]SwiftUI Plain Button Background Tap
When using a `SwiftUI` `Button` with `.buttonStyle(.plain)`, the background of the button may not react to tap gestures. One may run into this situation when using a more complex composition of UI elements as a button label. To make the background of the button respond to user interactions, use the modifier `.contentShape()`. Usually `.contentShape(Rectangle())` is a fitting choice.
[more ...]Dragging a SwiftUI View
Using `DragGesture` a floating movable `Button` can be easily implemented. Use the `.offset()` view modifier to shift the position of the movable view. Use the `DragGesture` to record dragging events and adjust the offset for the movable view.
[more ...]TextEditor and AttributedString
With platform versions 26 `TextEditor` now supports `AttributedString` allowing to edit styled text. The data is stored in an `AttributedString` and the `TextEditor` accesses it using a `Binding`. Use the initializer `init(text: Binding< AttributedString >, selection: Binding< AttributedTextSelection >? = nil)` for that.
[more ...]Sudoku - Solver Views
This article is part of a series in which a Sudoku game is implemented. As a fourth step, the views for the solver are built.
An InputView is added so the user can set a number in a cell. The views are adjusted so the list of allowed numbers is shown in the free cells.
[more ...]Sudoku - Solver
This article is part of a series in which a Sudoku game is implemented. As a third step, a solver is built.
The SudokuGenerator is modified and includes a new updateAllowedNumbers function. The SudokuModel is adjusted with new properties to hold state for the solving process.
[more ...]Sudoku - Generator Views
This article is part of a series in which a Sudoku game is implemented. As a second step, a generator view for showing Sudokus is built.
The SudokuGeneratorView holds a model class SudokuModel and includes Buttons for generating a random sudoku field. The SudokuGenerator is instantiated when needed only.
[more ...]Sudoku - Generator
This article is part of a series in which a Sudoku game is implemented. As a first step, a generator to create random Sudokus is built.
The class SudokuGenerator fills a model class SudokuModel with random numbers for a correct sudoku field. A random selection of cells is chosen to be cleared. This approach ensures, that a solution for the sudoku exists.
[more ...]Create Morse Code and Play it - Morse Code Views
This article is part of a series in which a morse code player is implemented. As a third step, the views are built, which tie everything together.
There are two views. A player view for controlling the MorseCodePlayer. The second view is the main view, which holds all model instances and contains the player view.
[more ...]Create Morse Code and Play it - Morse Code Player
This article is part of a series in which a morse code player is implemented. As a second step, a class is implemented, which prepares the beep sounds and can play them.
The `AVFoundation` framework can be used to generate sounds and play them. The short and long beeps are computed using the sinus function.
[more ...]Create Morse Code and Play it - Morse Code Creator
This article is part of a series in which a morse code player is implemented. As a first step, a class is implemented, which converts text to morse code.
The class MorseCodeCreator creates two outputs. One is an AttributedString with differing colours for each encoded word. The other is a sequence of character, which can be later used to play the morse code with all the typical pauses already in place.
[more ...]Swift Networking Simple Request with Query
Performing network communication in Swift is enabled using URLSession. A very simple request can be implemented with the asynchronous method `data(from: URL)` using just a couple of code lines.
Parameters for the request can be sent with query parameters. Use `URLComponents` and `URLQueryItem` for that. These types handle conversion of special characters and save you from implementing complicated checks of edge cases.
[more ...]Vibe Coding: JavaScript Game Encryption Protolock
The project served as a test how well a small game can be implemented using vibe coding. The goal was to create a "light-out puzzle" game using HTML and JavaScript. The inspiration came from a mini game called "Mezzonic Protolock" https://www.wowhead.com/quest=65461/your-first-mezzonic-protolock
[more ...]SwiftUI QR Code Generation
The CoreImage framework provides features to create a QR code. Importing `CIFilterBuiltins` adds access to the function `CIFilter.qrCodeGenerator()`, which returns a QR generator instance.
[more ...]Swift Networking IP Location
The location of an IP-address can be fetched with a very simple request from ip-api.com. With MapKit it is very easy to show it on a map.
[more ...]Swift Networking ISS Location
The location of the International Space Station can be fetched with a very simple request from api.open-notify.org. With MapKit it is very easy to show it on a map.
[more ...]SwiftUI 3D Chart
To create a 3D chart use `Chart3D`. In the example a data array is passed into the Chart3D call. To create a 3D scatter plot use `PointMark`. For a surface plot use `SurfacePlot`.
The feature has been tested with macOS 26 Tahoe and Xcode 26.
[more ...]Swift Foundation Models: Chat
Apple's Foundation Models Framework provides simple access to language models. The sample below shows, how to use a `LanguageModelSession` to send a message and react to a stream of responses.
The feature has been tested on a MacBook with Silicon processor, macOS 26 Tahoe and Xcode 26.
[more ...]Swift Networking Simple Request
Performing network communication in Swift is enabled using URLSession. A very simple request can be implemented with the asynchronous method `data(from: URL)` using just a couple of code lines.
For easy testing the Python package FastAPI provides a very simple and quick means. That way handling network requests can be tested in the simulator while the server can be started on the developer computer.
[more ...]SwiftUI Scatter Charts
SwiftUI Charts support creating scatter charts. To create a scatter chart, use a `Chart` view and place `PointMark`s or `LineMark`s inside.
[more ...]SwiftUI Bar Charts
SwiftUI Charts support creating bar charts. To create a bar chart, use a `Chart` view and place `BarMark`s inside.
[more ...]SwiftUI Pie Charts
SwiftUI Charts support creating pie charts since iOS 17. To create a pie chart, use a Chart view and place SectorMarks inside..
[more ...]SwiftUI Custom Circular Layout
Custom layouts in SwiftUI are provided using the protocol `Layout`. The `Layout` protocol requires to implement two methods `func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize` and `func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ())`.
[more ...]SwiftUI Filtered Table
A Table in SwiftUI is used to present data in rows and columns.
To create a table insert a Table view and nested in there TableColumns. Table data can be filtered and the table will update automatically. However, the filter process itself must be implemented by the developer.
[more ...]
SwiftUI Hierarchical Table
A Table in SwiftUI is used to present data in rows and columns. It can display hierarchical data and can be used as a tree view.
To create a table insert a Table view and nested in there TableColumns. To provide hierarchy, add a property to return the children or nil to the data record type and specify its keypath when configuring the Table.
[more ...]
Apple Intelligence ImagePlayground
ImagePlayground is an AI based image generation tool powered by Apple Intelligence.
To use ImagePlayground in SwiftUI a system sheet can be opened using the view modifier `.imagePlaygroundSheet(isPresented:,concept:,onCompletion:...)`. The feature is available since iOS 18.1.
[more ...]
SwiftUI Transition
Create custom transitions in SwiftUI using the protocol Transition using view modifiers .scaleEffect, .opacity, .rotationEffect, .blur and others.
[more ...]
SwiftUI Scroll Effects
ScrollViews in SwiftUI can be enhanced with scroll effects. To add scroll effects the view modifier .scrollTransition is available. The sample below shows offset effects and rotation effects.
[more ...]
SwiftUI Animations
Basic Animations in SwiftUI can easily be created using state variables and adjusting them within withAnimation blocks. In this example a view's offset is controlled using a drag gesture. When dragging exceeds a threshold, a new animation is started.
[more ...]
SwiftUI Table
A Table in SwiftUI is used to present data in rows and columns. It provides features for sorting, selection and more.
To create a table insert a Table view and nested in there TableColumns.
[more ...]
SwiftUI NavigationSplitView
NavigationSplitViews can be used with two or three column layout. Selections are managed with NavigationLink(value:,label:) and navigationDestination(for:,destination:). The call to navigationDestination has to be placed in a superview of the NavigationLinks. The destination views of the navigation destinations will be inserted in the next-level container. This may be content or detail.
[more ...]
SwiftUI ColorPicker
A `ColorPicker` is a standard component to select a color. Use it by adding `ColorPicker` and give it a binding to a `Color` state.
[more ...]
SwiftUI Shapes
Using SwiftUI shapes is simple. Shapes can be added to views by just creating them with Circle(), Rectangle() or one of the others.
[more ...]
Basic SwiftUI Charts
Creating a chart is very simple. There is a Chart view and that view has some marks like LineMark views.
[more ...]

