Reputation: 1182
I cant create saperate custom popview.. so I have tried like below mentioned one of the answer
here is storyboard view hierarchy
popBG view background colour is black with alpha = 0.3
this is code:
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var popViewtop: UIView!
@IBOutlet weak var testTable: UITableView!
@IBOutlet weak var popView: UIView!
@IBOutlet weak var popBG: UIView!
override func viewDidLoad() {
super.viewDidLoad()
popViewtop.isHidden = true
}
@IBAction func testBtn(_ sender: Any) {
popViewtop.isHidden = false
}
@IBAction func btnPop(_ sender: Any) {
let viewController = self.storyboard?.instantiateViewController(withIdentifier: "NewZoomAddressViewController") as! NewZoomAddressViewController;
popViewtop.isHidden = true
self.navigationController?.pushViewController(viewController, animated: true);
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}
}
now the tableview and button are not showing transperently.. only popbg and popview coming.. did i miss anything..
Actually i need like this: total backgroundview in some darkcolour and popupview heighlighted in white colour
Upvotes: 1
Views: 1594
Reputation: 14417
Make your Popup view full screen ..which have background and have subview as popUp over that background ...so you dont need to change anything once you show or hide popup and its easy to implement... Full screen UIView
having popUp UIView
over it
You should have a view called it MainPopUpView ... in this view you will add two UIViews ...
-> backGround UIView full screen (with alpha 0.3)
MainPopUpView
-> popUpView short & centre and shows actual content
So MainPopUpView have two views ...
here is the hierarchy
Upvotes: 1
Reputation: 4037
other way to achieve like your final image.. custom pop controller avoids this situation
put your popupView
in a custom viewController, then
@IBAction func addAddressBtn(_ sender: Any) {
present(PopupViewController(nibName: "PopupViewController", bundle: nil), animated: true) {}
}
Upvotes: 1
Reputation: 4038
view
's subView's alpha value changes, including popupView
popupView
view
's subView's alpha value does not change, including popupView
popupView
is a subView of view
,view
's alpha value affects its subviews's alpha.
view.addSubview(popupView)
Your current structure:
RootView->Subviews //Changing RootView alpha effects Subviews.
The solution is that the popupView
is not a subview of view
, which you show color changing with
Need a container view to separate from popupView
// backgroundColorChangeContainerView add other views ( tableView ... )
view.addSubview(backgroundColorChangeContainerView)
view.addSubview(popupView)
Upvotes: 2