Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwiftUI Update #17

Open
RMottram opened this issue Aug 19, 2020 · 1 comment
Open

SwiftUI Update #17

RMottram opened this issue Aug 19, 2020 · 1 comment

Comments

@RMottram
Copy link

Make a version for SwiftUI Framework

@Fred10932
Copy link

Fred10932 commented Jan 8, 2022

For folks looking how to use this in SwiftUI:

struct TwinkleView: UIViewRepresentable {
    @State var rect: CGRect
    
    func makeUIView(context: Context) -> UIView {        
         let view = UIView(frame: rect) 
         view.clipsToBounds = false         
         view.twinkle()         
         return view
     }     
     func updateUIView(_ uiView: UIView, context: Context) {
     }
}

//Use like this: 
 
SomeSwiftUIView()
   .overlay(
        GeometryReader { geometry in       //It currently doesn't work without explicitly passing the frame like this
             TwinkleView(rect: CGRect(x: 0, y: 0, width: geometry.size.width, height: geometry.size.height))
         }      
   )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants