Post

Replies

Boosts

Views

Activity

How to animate substring in a Text?
Currently, I am using multiple Texts in a horizontal stackview, to achieve animation of substring. As you can see in the above animation, the text - conversation - meeting - lecture are animated. However, there shortcoming of such an approach. Text size is not consistent among different Text block. The following Text block are having different text size. - Transform - conversation/ meeting/ lecture - to Quick Note Any idea how we can achieve, so that all text blocks have same text size so that they appear like 1 sentence? Or, how we can make the text blocks having constant text size, but able to perform line wrapping to next line, so that they appear like 1 sentence? Currently, this is the code snippet I am using. import SwiftUI struct ContentView: View { var array = ["lecture", "conversation", "meeting"] @State var currentIndex : Int = 0 @State var firstString : String = "" var body: some View { VStack { HStack { Text("Transform") .lineLimit(1) .minimumScaleFactor(0.5) .font(.title) Text(firstString) .lineLimit(1) .minimumScaleFactor(0.5) .font(.title) .transition(AnyTransition.opacity.animation(.easeInOut(duration:1.0))) .background(.yellow) Text("to Quick Note") .lineLimit(1) .minimumScaleFactor(0.5) .font(.title) }.padding() } .animation(.default) .onAppear { firstString = array[0] let timer = Timer.scheduledTimer(withTimeInterval: 2.0, repeats: true) { _ in if currentIndex == array.count - 1 { self.firstString = array[0] currentIndex = 0 } else { self.firstString = array[currentIndex+1] currentIndex += 1 } } } } } #Preview { ContentView() }
2
0
459
Dec ’24
Managing Legacy Subscriptions on the App Store
I have several subscription plans in the App Store that I no longer wish to offer to new users. In my app, these old subscriptions are hidden, but they remain active so existing subscribers can continue their plans and be charged as usual. However, some new users are still able to switch to these old subscription plans through the App Store. What is the best solution for this situation? I want to continue serving existing subscribers while preventing new users from subscribing to these legacy plans. Thank you.
2
0
256
Sep ’25
What is a reliable way, to check user system locale is using 12-hours or 24-hours format?
We would like to know, whether a user system locale is using 12-hours or 24-hours format? There are many proposed solutions at https://stackoverflow.com/q/1929958/72437 One of the solutions are let formatString = DateFormatter.dateFormat(fromTemplate: "j", options: 0, locale: Locale.current)! let hasAMPM = formatString.contains("a") However, to me, this is not a correct solution. When I tested with de_DE (German is using 24-hours), the returned string is HH 'Uhr' What is Uhr mean for? I guess it mean "clock" in German? There are so many other locales and one of them might contain letter a. Does anyone know, what is a correct way, to check whether user system locale is using 12-hours or 24-hours format?
3
0
881
Feb ’23
nonisolated Execution Differences Before and After Xcode 26.2
I have an older project that was created before Xcode 26.2. In Xcode versions prior to 26.2, there was no Swift Compiler – Concurrency build setting. With those older versions, the following behavior occurs: a nonisolated function executes off the main thread. class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() run() } private func run() { Task { await runInMainThread() } } func runInMainThread() async { print(">>>> IN runInMainThread(), Thread.isMainThread \(Thread.isMainThread)") await runInBackgroundThread() } private nonisolated func runInBackgroundThread() async { print(">>>> IN runInBackgroundThread(), Thread.isMainThread \(Thread.isMainThread)") } } Output: >>>> IN runInMainThread(), Thread.isMainThread true >>>> IN runInBackgroundThread(), Thread.isMainThread false However, starting with Xcode 26.2, Apple introduced the Swift Compiler – Concurrency settings. When running the same code with the default configuration: Approachable Concurrency = Yes Default Actor Isolation = MainActor This is the output Output: >>>> IN runInMainThread(), Thread.isMainThread true >>>> IN runInBackgroundThread(), Thread.isMainThread true the nonisolated function now executes on the main thread. This raises the following questions: What is the correct Swift Compiler – Concurrency configuration if I want a nonisolated function to run off the main thread? Is nonisolated still an appropriate way to ensure code runs on a background thread?
3
0
191
3w
Why the show/ hide table view mechanism doesn't work in non iPhone SE simulator?
I am using the following mechanism, to perform UITableView's row show and hide. class TableViewController: UITableViewController { private var hiddenIndexPaths : Set<IndexPath> = [] override func viewDidLoad() { super.viewDidLoad() } @IBAction func toggle(_ sender: UISwitch) { if sender.isOn { show(1) show(2) } else { hide(1) hide(2) } tableView.beginUpdates() tableView.endUpdates() } private func isHidden(_ indexPath: IndexPath) -> Bool { hiddenIndexPaths.contains(indexPath) } private func hide(_ item: Int) { hiddenIndexPaths.insert(IndexPath(item: item, section: 0)) } private func show(_ item: Int) { hiddenIndexPaths.remove(IndexPath(item: item, section: 0)) } override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { if isHidden(indexPath) { return 0.0 } return super.tableView(tableView, heightForRowAt: indexPath) } } As you can see, it works great in iPhone SE simulator (Works well in iPhone SE real device too) iPhone SE simulator linkText However, in non iPhone SE simulator (Like iPhone 13), once the table row is hidden, it can no longer be shown. Please refer to the following video. iPhone 13 simulator I am not sure what will its behavior in iPhone 13 real device, because I do not have access. I was wondering, do you have any idea why such issue occurs? If you are interested to test, here's the complete workable sample - https://github.com/yccheok/show-hide-table-row-bug
Topic: UI Frameworks SubTopic: UIKit Tags:
4
0
1.1k
Sep ’22
How to animate substring in a Text?
Currently, I am using multiple Texts in a horizontal stackview, to achieve animation of substring. As you can see in the above animation, the text - conversation - meeting - lecture are animated. However, there shortcoming of such an approach. Text size is not consistent among different Text block. The following Text block are having different text size. - Transform - conversation/ meeting/ lecture - to Quick Note Any idea how we can achieve, so that all text blocks have same text size so that they appear like 1 sentence? Or, how we can make the text blocks having constant text size, but able to perform line wrapping to next line, so that they appear like 1 sentence? Currently, this is the code snippet I am using. import SwiftUI struct ContentView: View { var array = ["lecture", "conversation", "meeting"] @State var currentIndex : Int = 0 @State var firstString : String = "" var body: some View { VStack { HStack { Text("Transform") .lineLimit(1) .minimumScaleFactor(0.5) .font(.title) Text(firstString) .lineLimit(1) .minimumScaleFactor(0.5) .font(.title) .transition(AnyTransition.opacity.animation(.easeInOut(duration:1.0))) .background(.yellow) Text("to Quick Note") .lineLimit(1) .minimumScaleFactor(0.5) .font(.title) }.padding() } .animation(.default) .onAppear { firstString = array[0] let timer = Timer.scheduledTimer(withTimeInterval: 2.0, repeats: true) { _ in if currentIndex == array.count - 1 { self.firstString = array[0] currentIndex = 0 } else { self.firstString = array[currentIndex+1] currentIndex += 1 } } } } } #Preview { ContentView() }
Replies
2
Boosts
0
Views
459
Activity
Dec ’24
Managing Legacy Subscriptions on the App Store
I have several subscription plans in the App Store that I no longer wish to offer to new users. In my app, these old subscriptions are hidden, but they remain active so existing subscribers can continue their plans and be charged as usual. However, some new users are still able to switch to these old subscription plans through the App Store. What is the best solution for this situation? I want to continue serving existing subscribers while preventing new users from subscribing to these legacy plans. Thank you.
Replies
2
Boosts
0
Views
256
Activity
Sep ’25
What is a reliable way, to check user system locale is using 12-hours or 24-hours format?
We would like to know, whether a user system locale is using 12-hours or 24-hours format? There are many proposed solutions at https://stackoverflow.com/q/1929958/72437 One of the solutions are let formatString = DateFormatter.dateFormat(fromTemplate: "j", options: 0, locale: Locale.current)! let hasAMPM = formatString.contains("a") However, to me, this is not a correct solution. When I tested with de_DE (German is using 24-hours), the returned string is HH 'Uhr' What is Uhr mean for? I guess it mean "clock" in German? There are so many other locales and one of them might contain letter a. Does anyone know, what is a correct way, to check whether user system locale is using 12-hours or 24-hours format?
Replies
3
Boosts
0
Views
881
Activity
Feb ’23
nonisolated Execution Differences Before and After Xcode 26.2
I have an older project that was created before Xcode 26.2. In Xcode versions prior to 26.2, there was no Swift Compiler – Concurrency build setting. With those older versions, the following behavior occurs: a nonisolated function executes off the main thread. class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() run() } private func run() { Task { await runInMainThread() } } func runInMainThread() async { print(">>>> IN runInMainThread(), Thread.isMainThread \(Thread.isMainThread)") await runInBackgroundThread() } private nonisolated func runInBackgroundThread() async { print(">>>> IN runInBackgroundThread(), Thread.isMainThread \(Thread.isMainThread)") } } Output: >>>> IN runInMainThread(), Thread.isMainThread true >>>> IN runInBackgroundThread(), Thread.isMainThread false However, starting with Xcode 26.2, Apple introduced the Swift Compiler – Concurrency settings. When running the same code with the default configuration: Approachable Concurrency = Yes Default Actor Isolation = MainActor This is the output Output: >>>> IN runInMainThread(), Thread.isMainThread true >>>> IN runInBackgroundThread(), Thread.isMainThread true the nonisolated function now executes on the main thread. This raises the following questions: What is the correct Swift Compiler – Concurrency configuration if I want a nonisolated function to run off the main thread? Is nonisolated still an appropriate way to ensure code runs on a background thread?
Replies
3
Boosts
0
Views
191
Activity
3w
Why the show/ hide table view mechanism doesn't work in non iPhone SE simulator?
I am using the following mechanism, to perform UITableView's row show and hide. class TableViewController: UITableViewController { private var hiddenIndexPaths : Set<IndexPath> = [] override func viewDidLoad() { super.viewDidLoad() } @IBAction func toggle(_ sender: UISwitch) { if sender.isOn { show(1) show(2) } else { hide(1) hide(2) } tableView.beginUpdates() tableView.endUpdates() } private func isHidden(_ indexPath: IndexPath) -> Bool { hiddenIndexPaths.contains(indexPath) } private func hide(_ item: Int) { hiddenIndexPaths.insert(IndexPath(item: item, section: 0)) } private func show(_ item: Int) { hiddenIndexPaths.remove(IndexPath(item: item, section: 0)) } override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { if isHidden(indexPath) { return 0.0 } return super.tableView(tableView, heightForRowAt: indexPath) } } As you can see, it works great in iPhone SE simulator (Works well in iPhone SE real device too) iPhone SE simulator linkText However, in non iPhone SE simulator (Like iPhone 13), once the table row is hidden, it can no longer be shown. Please refer to the following video. iPhone 13 simulator I am not sure what will its behavior in iPhone 13 real device, because I do not have access. I was wondering, do you have any idea why such issue occurs? If you are interested to test, here's the complete workable sample - https://github.com/yccheok/show-hide-table-row-bug
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
4
Boosts
0
Views
1.1k
Activity
Sep ’22