Solved Finally
I solved this problem by making the custom UILable inside the UIViewController. This may not be the good practice, so kindly let me know if someone find the better solution then this.
func showTestAlert(message:String , viewController:UIViewController){
let customUiLableView:UILabel
let alert:UIAlertController
if((message.count) < 100){
alert = UIAlertController(title: "", message: "\n\n\n\n", preferredStyle: .alert)
customUiLableView = UILabel(frame: CGRect(x: 10, y: 0, width: 250, height: 120))
customUiLableView.numberOfLines = 4
}else if((message.count) < 200){
alert = UIAlertController(title: "", message: "\n\n\n\n\n\n", preferredStyle: .alert)
customUiLableView = UILabel(frame: CGRect(x: 10, y: 0, width: 250, height: 160))
customUiLableView.numberOfLines = 6
}else{
alert = UIAlertController(title: "", message: "\n\n\n\n\n\n\n\n", preferredStyle: .alert)
customUiLableView = UILabel(frame: CGRect(x: 10, y: 0, width: 250, height: 200))
customUiLableView.numberOfLines = 8
}
customUiLableView.text = message
customUiLableView.textAlignment = .center
customUiLableView.textColor = UIColor.darkGray
customUiLableView.font = UIFont(name: "Helvetica", size: 16.0)
let action = UIAlertAction(title: "OK", style: .default, handler: nil)
alert.view.addSubview(customUiLableView)
alert.addAction(action)
viewController.present(alert, animated: true, completion: nil)
}