SwiftUI.List allows for customization using .listItemTint, .tint, or .foregroundStyle. This can be used to color individual items in the list, other than the app's specified accent color.
Is there an equivalent feature to customize individual Tab's icon or label, when using TabView's SidebarAdaptableTabViewStyle, and its in the sidebar style.
From what I understand, there needs to be a modifier applied directly to Tab unlike List, and not just the label.
Since there isn't any color/tint modifiers, is it not possible?
SwiftUI
RSS for tagProvide views, controls, and layout structures for declaring your app's user interface using SwiftUI.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
My SwiftUI code runs fine on macOS, iOS(iPad) and larger iPhones, but will not display the detail view on smaller iPhones.
Is there a way to force the smaller iPhones to display the detail view?
And if not,
When I put the App on the Apple store, for sale, will the Apple store be smart enough to flag the App as not appropriate for smaller iPhones, such as the SE (2nd and 3rd gen.) and prevent downloads?
Thanks in advance for any guidance.
When compiled on Xcode 16.4.0:
When compiled on Xcode 26:
The code:
import SwiftUI
struct SearchBarController: UIViewRepresentable {
@Binding var text: String
var placeholderText: String
class Coordinator: NSObject, UISearchBarDelegate {
@Binding var text: String
init(text: Binding<String>) {
_text = text
}
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
text = searchText
}
}
func makeUIView(context: Context) -> UISearchBar {
let searchBar = UISearchBar(frame: .zero)
searchBar.delegate = context.coordinator
searchBar.placeholder = placeholderText
searchBar.searchBarStyle = .minimal
return searchBar
}
func updateUIView(_ uiView: UISearchBar, context: Context) {
uiView.text = text
}
func makeCoordinator() -> SearchBarController.Coordinator {
return Coordinator(text: $text)
}
}
Hi,
My app has an IAP and the view that let user to purchase is simply a ProductView. The purchase flow should be handled by the ProductView itself. I have tested the app with xcode storekit configuration, xcode run with sandbox account and also TestFlight environment as well. The purchase is triggered and the app feature is unlocked after purchase. However, I keep getting app review team feedback with the following problem:
Bug description: the purchase button is greyed out after we tapped on it, however, there's no purchase flow popped up
I have tried multiple things. Building with xcode cloud, removing the storekit configuration from the build scheme. But none can get the app review team to get through the problem.
The IAP is not available in certain region. In that case, the app will show a message. However, the app review attached an screenshot which shows the product view.
The view that allow users to purchase
if let product = store.products.first(where: { $0.id == "com.xxx.xxxxxxx" }) {
// If the product is available, show the ProductView
ProductView(id: product.id)
.productViewStyle(.compact)
} else {
// If the product is not available, show a message
Text("In-app purchase is not available in your region.")
}
The store class
@Published private(set) var products: [Product] = []
...
init() {
//To handle the parental approval flow
getUpdateTransaction()
}
func getUpdateTransaction() {
updates = Task {
for await update in StoreKit.Transaction.updates {
if let transaction = try? update.payloadValue {
await fetchActiveTransactions()
await transaction.finish()
}
}
}
}
Does anyone what can go wrong with ProductView? As this is part of the StoreKit API, I don't know what can go wrong. At least the purchase flow should be covered by it.
Also, is sandbox and TestFlight a good way to test IAP?
Thanks!
During the WWDC Session called "Design widgets for visionOS" the presenter says:
You can choose whether the background of your widget participates in tinting. If you opted out, for example to preserve a photo or illustration, make sure it still looks good alongside the selected color palette.
https://developer.apple.com/videos/play/wwdc2025/255
Unfortunately, this session has no example code. Can someone point me to the correct way to do this? Is there a modifier we can use on views?
When a user selects one the tint colors using the configuration screen, we would like to prevent some views from being tinted.
In our app we have a view with a custom scroll implementation in a TabView. We would like to programmatically minimize (not hide) the TabView, like .tabBarMinimizeBehavior(...) does when a List is behind the tab bar and a user scrolls. I haven't found any view modifier that I can attach that allows me to do so, is this not possible? I would have expected something like
.tabBarMinimized($tabBarMinimized)
Topic:
UI Frameworks
SubTopic:
SwiftUI
Hello Apple support,
I have this following code
Map(position: $mCam, selection: $lastSelection) {
// Display content conditionally based on camera scope.
// ^^^ works with user gesture, does not work with mapCameraKeyframeAnimator
}
.onMapCameraChange(frequency: .continuous , { context in
// save the camera scope
})
.mapCameraKeyframeAnimator(trigger: self.trigger, keyframes: { camera in
// frames
})
Context:
when logging, the .onMapCameraChange is updating. The content mapContentBuilder is running. But the content is NOT showing up on the map.
MapCircle, MapPolyline does not show! however, Marker works just fine
Question:
Anyone know How to indicate to MapKit Map view to draw the content?
Or how to have a slight "break" between animation keyframes, so map can catch up.
I have several locations in my app where the user can search. He can search within the apps content or search for content from the web to add to the app.
i would like to use the tab view search box for both, but I don’t know how to do that. I currently have a tab with value search for the „web search“ and a list with .searchable for the in app content. The later one adds the search bar on top of the list.
W
hat’s the best way to modify this behavior?
Topic:
UI Frameworks
SubTopic:
SwiftUI
When using the fullScreenCover API in iOS 26, the content of the displayed view overlaps the content of the view that triggered the fullScreenCover. This issue is not present in iOS 18 and earlier versions.
Feedback ID: FB19165084
Playing around with the new TabViewBottomAccessoryPlacement API, but can't figure out how to update the value returned by @Environment(\.tabViewBottomAccessoryPlacement) var placement.
I want to change this value programmatically, want it to be set to nil or .none on app start until user performs a specific action. (taps play on an item which creates an AVPlayer instance).
Documentation I could find: https://developer.apple.com/documentation/SwiftUI/TabViewBottomAccessoryPlacement
Hello,
I have a SwiftUI application that uses NavigationSplitView. It's working great on iOS, iPad, and macOS. I decided to give it a try on tvOS. After it builds, it will not allow user interaction on the NavigationSplitView's sidebar. I've tried various view focus modifiers without any success. I'd also expect this to "just work" as default behavior. I have filed FB13447961 on this issue. Here is a distillation of the code that demonstrates the problem. Any ideas? Thank you.
enum Category : String, CaseIterable {
case first
case second
case third
}
enum Detail : String, CaseIterable {
case one
case two
case three
}
struct DetailView : View {
let category : Category?
var body: some View {
if let category {
Text(category.rawValue)
List(Detail.allCases, id: \.self) { detail in
NavigationLink(value: detail) {
Text(detail.rawValue)
}
}
} else {
Text("Select Category")
}
}
}
struct ContentView: View {
// NOTE: If this category is set to something, it will show that category's detail.
// The problem is that the NavigationSplitView sidebar does not have, nor does not
// seem to be able to get focus.
@State var category: Category?
@State var path : [Detail] = []
var body: some View {
NavigationSplitView {
List(Category.allCases, id: \.self, selection: $category) { category in
Text(category.rawValue)
}
} detail: {
NavigationStack(path: $path) {
DetailView(category: category)
.navigationDestination(for: Detail.self) { detail in
Text("\(detail.rawValue)")
}
}
}
}
}
#wwdc2023-10162 #wwdc20-10042
I have been trying to get the drag and drop to work on iOS 26 betas. Single drag is okay, but I thought this year we were getting multi-select drag added.
creating a simple object that can be dragged. Using the .draggable and added dropDestination which does trigger. The problem is the dragContainer does nothing. Not really clear what it is supposed to do.
How am I supposed to allow for multiple item drag and drop like the Photos app? In there you can start a drag and tap additional photos to add to the drag. I can do this with a UICollectionView, but not with SwiftUI.
struct DragObject: Codable, Identifiable, Transferable {
var index: Int
enum Keys: String, CodingKey {
case index
}
var id:Int {
index
}
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: Keys.self)
try container.encode(self.index, forKey: .index)
}
static public var transferRepresentation: some TransferRepresentation {
CodableRepresentation(contentType: .json)
}
}
@available(iOS 26.0, *)
struct DragDropTestView: View {
@State var items : [DragObject] = (0..<100).map({ DragObject(index: $0) })
@State var selected : [DragObject.ID] = []
var body: some View {
let _ = Self._printChanges()
ScrollView {
Text("Selected \(selected)")
LazyVGrid(columns: [GridItem(.adaptive(minimum: 150, maximum: 180))],
alignment: .center,
spacing: 10)
{
ForEach(items, id: \.index) { item in
VStack {
Text("\(item.index)")
}
.frame(width: 100, height: 100)
.padding()
.background(Color.blue)
.cornerRadius(8)
.contentShape(.dragPreview, Circle())
.draggable(item)
.dropDestination(for: DragObject.self) { draggedItems, session in
print("Dragged Item Count: \(draggedItems.count)")
}
}
}
}
.dragContainer(for: DragObject.self, selection: selected){ ids in
dragItems(ids: ids)
}
}
func dragItems(ids: [Int]) -> [DragObject] {
return ids.map({ DragObject(index: $0)})
}
}
I'm unable to find the right combination modifiers to get drag and drop to work using the new .draggable(containerItemID:) and dragContainer(for:in:selection:_:) modifiers. The drag is initiated with the item's ID, the item is requested from the .dragContainer modifier, but the drop closure is never triggered.
Minimal repro:
struct Item: Identifiable, Codable, Transferable {
var id = UUID()
var value: String
static var transferRepresentation: some TransferRepresentation {
CodableRepresentation(contentType: .tab)
}
}
struct DragDrop: View {
@State var items: [Item] = [
Item(value: "Hello"),
Item(value: "world"),
Item(value: "something"),
Item(value: "else")
]
var body: some View {
List(items) { item in
HStack {
Text(item.value)
Spacer()
}
.contentShape(Rectangle())
.draggable(containerItemID: item.id)
.dropDestination(for: Item.self) { items, session in
print("Drop: \(items)")
}
}
.dragContainer(for: Item.self) { itemID in
print("Drag: \(itemID)")
return items.filter { itemID == $0.id }
}
}
}
#Preview("Simple") {
DragDrop()
}
In my visionOS app, I'm seeing this error in the console dozens of times. Anyone know what it means, or how to troubleshoot it?
Searching these forums and the usual other places hasn't come up with anything that seems relevant.
Hey,
The new "soft" scroll edge effect is really cool! But it seems to only appear when you add toolbar items.
Is there a way to add it for "custom" views as well, that I place in a safe area inset?
For example, the messages app in iOS 26 does this. There's a text field as a safe area inset as well as a soft scroll edge effect.
Thanks!
In SwiftUI sliders now have tick marks by default on iOS26, how do you turn them off or hide them? This WWDC talk had some sample code on how to set the tick marks but it doesn't compile for me: https://developer.apple.com/videos/play/wwdc2025/323/
I don't see any available methods or initializers to turn them off.
Hello everyone, I am having an issue where the attributed text that I have in my UITextView is not scaling dynamically with phone text size, whenever I remove the attributed text logic, it scales fine, however, with it, it stays at a set font size.
struct AutoDetectedClickableDataView: UIViewRepresentable {
let text: String
@Binding var height: CGFloat
func makeUIView(context: Context) -> UITextView {
let textView = UITextView()
textView.dataDetectorTypes = [.phoneNumber, .address, .link]
textView.isEditable = false
textView.isScrollEnabled = false
textView.backgroundColor = .clear
textView.font = UIFont.preferredFont(forTextStyle: .body) /*UIFontMetrics(forTextStyle: .body).scaledFont(for: UIFont.systemFont(ofSize: 16.0)) */
textView.adjustsFontForContentSizeCategory = true
textView.textContainer.lineBreakMode = .byWordWrapping
textView.textContainerInset = .zero
textView.textContainer.lineFragmentPadding = 0
textView.translatesAutoresizingMaskIntoConstraints = false
textView.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
textView.setContentHuggingPriority(.defaultHigh, for: .horizontal)
return textView
}
func updateUIView(_ uiView: UITextView, context: Context) {
let attributed = NSMutableAttributedString(string: text, attributes: [
.font: UIFont.preferredFont(forTextStyle: .body)
])
let detector = try? NSDataDetector(types: NSTextCheckingResult.CheckingType.address.rawValue |
NSTextCheckingResult.CheckingType.link.rawValue |
NSTextCheckingResult.CheckingType.phoneNumber.rawValue)
detector?.enumerateMatches(in: text, options: [], range: NSRange(location: 0, length: text.utf16.count)) { match, _, _ in
guard let match = match else { return }
attributed.addAttributes([
.foregroundColor: UIColor.systemBlue,
.underlineStyle: NSUnderlineStyle.single.rawValue,
], range: match.range)
}
uiView.attributedText = attributed
// uiView.text = text
DispatchQueue.main.async {
uiView.layoutIfNeeded()
let fittingSize = CGSize(width: uiView.bounds.width, height: .greatestFiniteMagnitude)
let size = uiView.sizeThatFits(fittingSize)
height = size.height
}
}
}
Will there be a way to replicate the clear glass effect used on sliders and toggles?
I have a custom slider with enhanced functionality, and have done the best job I can to make it look similar. However, this is as clear as the glass gets
Topic:
UI Frameworks
SubTopic:
SwiftUI
I have the following SwiftUI code for a draggable UI.
private var onTouchDownGesture: some Gesture {
DragGesture(minimumDistance: 0)
.onChanged { value in
isDragging = true
updateYTranslation(value.translation.height)
}
.onEnded { value in
isDragging = false
updateYTranslation(value.translation.height)
}
}
var body: some View {
VStack {
Image(systemName: "chevron.up")
Spacer()
.frame(height: 16)
Image(systemName: "chevron.down")
}
.padding()
.gesture(onTouchDownGesture)
.glassEffect(.regular.interactive(false))
}
}
I find that if I use glassEffect modifier, then the drag gesture will not work. However, if i change it glasseffectto other kinds of background like .background(Capsule()), then the drag gesture works as expected.
Is this a known issue of glassEffect or am I using it incorrectly?
i am using this code but no works
@FocusState private var focus: FormFieldFocus?
let db = getDatabaseConnection()
var body: some View {
VStack {
Group {
Text("Item Num:").padding(1)
TextField("Item Num", text: $intemNum)
.textFieldStyle(.roundedBorder)
.onSubmit {focus = .despTxt}
.focused($focus, equals: .itemTxt)
.background(focus ? Color.yellow.opacity(0.3) : Color.clear)
.cornerRadius(10)
Topic:
UI Frameworks
SubTopic:
SwiftUI