How to add floating button on top of the UITableVi

2019-04-27 13:26发布

I need to add floating button on top of UITableViewController.

The following link is used for adding FloatingButton action on top of UIViewController

Creating a floating menu in an iOS application

I already tried to add this floating button to my UITableViewController but it is not visible.

please help me thank you inadvance

2条回答
叛逆
2楼-- · 2019-04-27 13:57
  1. First add the UITableView and then the Button. So it should be like this in the XIB Structure (Button is after the Table not before otherwise it will be hidden):

XIB Structure

  1. Set the Button Constraints related to the Super View and not related to UITableView.

Button Constraints

See that button constraints are related to superview. This is important if you want the Floating Button.

If everything is done correctly it would show like this: enter image description here

查看更多
家丑人穷心不美
3楼-- · 2019-04-27 14:06

Floating Action button on IOS can be created with way more easier way:

  1. Take a button from object library and place it where ever you want it to be placed.
  2. Give its height and width 48x48.
  3. Connect your button to your class and set its corner raidius to 25

    yourButton.layer.cornerRadius = 25

There you have your Fab button.

查看更多
登录 后发表回答