Post

Replies

Boosts

Views

Created

Change text color for large titles
How can I chage the text color for large titles? I want it to be white.I tried to set the titleTextAttributes like this:self.navigationController?.navigationBar.prefersLargeTitles = true self.navigationController?.navigationBar.titleTextAttributes = [ NSAttributedStringKey.foregroundColor.rawValue: UIColor.white ]But the text only turns up white when I scroll and it is displayed in the middle as usual.
7
0
7.4k
Jun ’17
SwiftUI List performane
I have a performance issue with List when I have a large amount of data that is replaced. Given the code below, a data set of about 3500 name items are loaded from a fetch request. Depending of the selected gender in the segmented picker these items are filtered and the displayed in the List. When the List first render I have no performance issue with the loading and rendering of items. It scrolls nicely and smoothly through 1700 items. But as soon as I switch gender through the segemented picker it takes about 30-45 seconds to render the List again.I think this has to do with removing 1700 items and the inserting 1500 items again from the List. Is there a best practice how to reload a large amount of items in SwiftUI? Or can I reset the List before I load it again, since there is no issue initially.Anyone else having issue same issue?struct NameList: View { @ObservedObject fileprivate var global = GlobalSettings() @FetchRequest( entity: Name.entity(), sortDescriptors: [NSSortDescriptor(key: "name", ascending: true)] ) var names: FetchedResults<Name> @State var selectedGender = Defaults.gender var body: some View { let filtered = names.filter { $0.gender == self.selectedGender } return NavigationView { VStack { Picker("Gender", selection: $global.gender) { Text(Gender.female.rawValue.uppercased()) .tag(Gender.female) Text(Gender.male.rawValue.uppercased()) .tag(Gender.male) Text(Gender.unisex.rawValue.uppercased()) .tag(Gender.unisex) } .pickerStyle(SegmentedPickerStyle()) .padding() List( filtered, id: \.self) { (item: Name) in NameListRow(item: item) } } } .onReceive(Defaults.publisher(for: \.gender)) { (gender) in self.selectedGender = gender } } }
17
0
14k
Oct ’19