Post

Replies

Boosts

Views

Activity

Reply to hello
Please, explain what is your question take some care when you post code to make it easier to read: ZStack { LinearGradient(gradient: Gradient(colors: [Color.orange, Color.yellow, Color.white]), startPoint: .top, endPoint: .bottom) .edgesIgnoringSafeArea(.all) SwiftUIView() boton() .font(Font.system(size: 80)) .offset(x: 10, y: -10) } UIScreen.main.brightness = 0.1 // between 0 and 1 } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } what do you do with line 12, copied in the middle of the code ? It should be inside some func (like a Button action) what is boton() ?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to How to animate a CATransform3DRotate ?
I see at least 2 ways: create a CoreAnimation with the transform keyPath let trans = CABasicAnimation(keyPath: "transform"); trans.fromValue = [0.0, 0.0, 1.0, 0.0] // you may have to correct this trans.toValue = [rotationAngle * .pi / 180.0, 0.0, 1.0, 0.0] // That's my guess of the correct set of parameters button.layer.add(cotransor, forKey: "rotation") // I am not sure of the keyPath to use For the list of keyPaths: https://stackoverflow.com/questions/44230796/what-is-the-full-keypath-list-for-cabasicanimation call animate on the view UIView.animate(withDuration: 2.0, delay: 0.0, options: .curveEaseOut, animations: { /* TRANSFORM */ }, completion: { (done) in } ) with the right animations and completion handler
Topic: UI Frameworks SubTopic: UIKit Tags:
Apr ’21
Reply to Rearrange collection view cells within it's section
Yes, that's a clean way to do it with func collectionView(_ collectionView: UICollectionView, targetIndexPathForMoveFromItemAt originalIndexPath: IndexPath, toProposedIndexPath proposedIndexPath: IndexPath) - IndexPath And gives equivalent result to what I proposed. Note: for user experience, alerting (as I explained) why he cannot move would be useful.
Topic: UI Frameworks SubTopic: UIKit Tags:
Apr ’21
Reply to Uppgradera Swiftkod
So, you have a code that was developed with Xcode 6.4 ? Which Xcode do you want to use now ? You may have to upgrade several times, correct the code each time, with intermediate versions of Xcode (something like): 6.4 - 8 8 - 10 10 - 12 You can download older versions of Xcode here : https://developer.apple.com/download/more/ Another way is to create a new project, rebuild the Storyboard and paste as much code as you can. Så har du en kod som har utvecklats med Xcode 6.4? Vilken Xcode vill du använda nu? Du kan behöva uppgradera flera gånger, korrigera koden varje gång, med mellanversioner av Xcode (ungefär som): 6.4 - 8 8 - 10 10 - 12 Du kan ladda ner äldre versioner av Xcode här: https://developer.apple.com/download/more/ Ett annat sätt är att skapa ett nytt projekt, bygga om Storyboard och klistra in så mycket kod som möjligt.
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to Errors in ForEach SwiftUI
I don't understand what you want to show in Section and what you do in ForEach. In addition, your naming of var is awfully confusing main used in different places for different things users as plural but not an array… weather singular but several values in array If I understand what you want to do, you should probably: Section { ForEach(networkController.users.weather ?? [], id: \.self){ userWeather in // rename user Text(userWeather.main ?? "") } // ForEach is meaningless here ForEach(networkController.users.main ?? Main(temp: 0), id: \.self){ user in // Text("\(user.temp)") Text( "\(networkController.users.main ?? Main(temp: 0)).temp)") }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21