简体   繁体   English

如何以编程方式在目标c中创建浮雕按钮?

[英]How to create an embossed button in objective c programmatically?

How can I create a styled button like the one showed below? 如何创建如下所示的样式按钮? I know Facebook is using the Three20 framework to generate the buttons programmatically. 我知道Facebook正在使用Three20框架以编程方式生成按钮。 I think it's overwhelming. 我认为这是压倒性的。

I'm rather new developer of ios so I wonder what is the most common way to create buttons like this? 我是ios的新开发者,所以我想知道创建这样的按钮最常用的方法是什么? (except for using images). (使用图像除外)。

Facebook iPhone App

Simple way to create is 简单的创建方法是

  1. Create UIButton programmatically 以编程方式创建UIButton
  2. Use gradient to create that background effect. 使用渐变来创建背景效果。

To create gradient for back ground use: CAGradientLayer, CAGradientLayer.frame and CAGradientLayer.color 为背景创建渐变用途:CAGradientLayer,CAGradientLayer.frame和CAGradientLayer.color

Assign gradient to the button use: AddSublayer, CornerRadius, and MasksToBounds on UIButton. 为使用按钮分配渐变:UIButton上的AddSublayer,CornerRadius和MasksToBounds。

  1. You can use Jess Martin's CoolButton that draws glassy iOS style buttons, all using CoreGraphics and no images - https://github.com/jessmartin/CoolButtons 您可以使用Jess Martin的CoolButton绘制玻璃iOS风格的按钮,全部使用CoreGraphics并且没有图像 - https://github.com/jessmartin/CoolButtons
  2. Jeff Lamarche's iPhone Gradient buttons - http://code.google.com/p/iphonegradientbuttons/ Jeff Lamarche的iPhone Gradient按钮 - http://code.google.com/p/iphonegradientbuttons/

Look at related questions on StackOverflow. 查看StackOverflow上的相关问题。

When I want a button like that I tend to just create it in software such as Photoshop. 当我想要一个像这样的按钮时,我倾向于在Photoshop等软件中创建它。 Then you can just set a UIButton to have a custom style and setup the image as the button background. 然后,您可以将UIButton设置为具有自定义样式,并将图像设置为按钮背景。

Here is a nice tutorial on creating button in photoshop. 这是一个关于在photoshop中创建按钮的精彩教程 Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM