【问题标题】:Show rectangular button using the library Floaty使用库 Floaty 显示矩形按钮
【发布时间】:2019-03-12 07:56:19
【问题描述】:

我正在使用Floaty 库(This 之一)的浮动按钮。它确实也像这样正确显示了浮动按钮

但我希望浮动按钮看起来像这样......

这里标题为“贡献”的黄色按钮是我想要 Floaty 提供的

【问题讨论】:

  • 普通的 UI Button 怎么样?
  • 如果你想按你的要求按钮,你需要在你的浮动库中进行更改。表示高度、宽度和位置
  • True @iOSTeam 但这就是我无法弄清楚的……:)

标签: ios swift floating-action-button


【解决方案1】:

这里需要为Floaty设置两个属性

floaty.buttonImage = UIImage(named: "yourimage") //this will set your image
floaty.paddingX = self.view.frame.width/2 - floaty.frame.width/2 //this will set it to center.

当你点击这个按钮时还有旋转,所以你需要去Floaty类然后搜索下面的行并评论它。

self.plusLayer.transform = CATransform3DMakeRotation(self.degreesToRadians(self.rotationDegrees), 0.0, 0.0, 1.0)
self.buttonImageView.transform = CGAffineTransform(rotationAngle: self.degreesToRadians(self.rotationDegrees))

还有

self.plusLayer.transform = CATransform3DMakeRotation(self.degreesToRadians(0), 0.0, 0.0, 1.0)
self.buttonImageView.transform = CGAffineTransform(rotationAngle: self.degreesToRadians(0))

【讨论】:

  • 好的@Dharmesh。我试过了,但浮动按钮仍然显示为圆形,而我希望它是带有圆角的矩形,如所附的第二张图片所示......
  • 您是否按照我的建议添加了图片?
  • 它应该可以工作。你能分享你正在尝试这个的任何演示项目吗?
  • 它不是椭圆形的图像。但只是标题“贡献”左侧的小图像。它实际上是我想要的椭圆形按钮..
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-28
  • 1970-01-01
  • 2017-11-07
  • 2020-09-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多