I have this view :
and this is its code :
class CustomDialog: UIView {
var vc: UIViewController!
var view: UIView!
@IBOutlet weak var titleLabel: UILabel!
....
required init?(coder: NSCoder) {
super.init(coder: coder)
}
init(frame: CGRect, inView: UIViewController) {
super.init(frame: frame)
xibSetup(frame: CGRect(x: 0, y: 0, width: frame.width, height: frame.height))
vc = inView
}
func xibSetup(frame: CGRect){
self.view = loadNibView()
view.frame = frame
addSubview(view)
}
func loadNibView() -> UIView {
let bundle = Bundle(for: type(of: self))
let nib = UINib(nibName: "CustomDialog", bundle: bundle)
let view = nib.instantiate(withOwner: self, options: nil).first as! UIView
return view
}
}
I am loading my view like this:
public class FlutterTheoryPlugin: NSObject, FlutterPlugin
{
var customDialog: CustomDialog!
public static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterMethodChannel(name: Constants.METHOD_CHANNEL_NAME, binaryMessenger: registrar. Messenger())
let instance = FlutterTheoryPlugin()
registrar.addMethodCallDelegate(instance, channel: channel)
}
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
switch call.method {
case Constants.INITIATE_EVENTS:
let viewController: UIViewController =
(UIApplication.shared.delegate?.window??.rootViewController)!;
let basisAlert = TheoryAlert()
basisAlert.showBaseAlert(viewController: viewController)
result(true)
default:
result(FlutterMethodNotImplemented)
}
}
}
class TheoryAlert {
var customDialog: CustomDialog!
private let backgroundView: UIView = {
let backgroundView = UIView()
backgroundView.backgroundColor = .black
backgroundView.alpha = 0
return backgroundView
}()
private let alertView: UIView = {
let alert = UIView()
alert.backgroundColor = .white
alert.layer.masksToBounds = true
alert.layer.cornerRadius = 12
return alert
}()
func showBaseAlert(viewController: UIViewController) {
guard let targetView = viewController.view else {
return
}
backgroundView.frame = targetView.bounds
targetView.addSubview(backgroundView)
targetView.addSubview(alertView)
alertView.frame = CGRect(x: 40, y: -300, width: targetView.frame.size.width, height: 300)
self.customDialog = CustomDialog(frame: targetView.frame, inView: viewController)
alertView.addSubview(customDialog)
UIView.animate(withDuration: 0.25, animations: {
self.backgroundView.alpha = 0.6
}, completion: {
done in
if done {
UIView.animate(withDuration: 0.25, animations: {
self.alertView.center = targetView.center
})
}
})
}
}
When I am using my IOS plugin on my flutter app , all view want s to be shown, but I need just the view, this is the result on the Flutter:

