How to add floating button on top of the UITableView?

假如想象 提交于 2019-12-09 16:51:45

问题


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


回答1:


  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):

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

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:




回答2:


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.



来源:https://stackoverflow.com/questions/37073935/how-to-add-floating-button-on-top-of-the-uitableview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!