addSubview SwiftUI View to UIKit UIView in Swift

Step 1: Create instances of UIHostingController by using SwiftUI View struct ContentView : View { var body: some View { VStack { Text(“Test”) Text(“Test2”) } } } var child = UIHostingController(rootView: ContentView()) Step 2: Add instance of UIHostingController as a child view controller to Any UIKit ViewController var parent = UIViewController() child.view.translatesAutoresizingMaskIntoConstraints = false child.view.frame … Read more

CGRectMake, CGPointMake, CGSizeMake, CGRectZero, CGPointZero is unavailable in Swift

CGRect Can be simply created using an instance of a CGPoint or CGSize, thats given below. let rect = CGRect(origin: CGPoint(x: 0,y :0), size: CGSize(width: 100, height: 100)) // Or let rect = CGRect(origin: .zero, size: CGSize(width: 100, height: 100)) Or if we want to specify each value in CGFloat or Double or Int, we … Read more