Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 带边框的透明按钮_Iphone_Ios_Objective C_Uibutton_Transparency - Fatal编程技术网

Iphone 带边框的透明按钮

Iphone 带边框的透明按钮,iphone,ios,objective-c,uibutton,transparency,Iphone,Ios,Objective C,Uibutton,Transparency,我试图通过使按钮透明,但仍然有边框的按钮来获得这种效果。当我制作透明图像时,出于某种原因,它们会使按钮变大。下面是一些效果的例子 在第一幅图像中,导航栏上的按钮对于导航栏的背景是半透明的 在左侧的第二个图像中,“Action Composer”按钮是透明的,但仍然有边框。试试这个: 这将创建一个透明按钮: UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom]; button.frame GRectMake(x, y, w

我试图通过使按钮透明,但仍然有边框的按钮来获得这种效果。当我制作透明图像时,出于某种原因,它们会使按钮变大。下面是一些效果的例子

在第一幅图像中,导航栏上的按钮对于导航栏的背景是半透明的

在左侧的第二个图像中,“Action Composer”按钮是透明的,但仍然有边框。

试试这个:

这将创建一个透明按钮:

UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
button.frame  GRectMake(x, y, w, h);
[button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"Button" forState:UIControlStateNormal];
button.backgroundColor=[UIColor clearColor];
[button setTitleColor:[UIColor colorWithRed:0.3 green:0.1 blue:0.4 alpha:1.0] forState:UIControlStateNormal];
[self.view addSubview:btn];
现在是边境:

[[button layer] setBorderWidth:2.0f];
[[button layer] setBorderColor:[UIColor greenColor].CGColor];
试试这个:

这将创建一个透明按钮:

UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
button.frame  GRectMake(x, y, w, h);
[button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"Button" forState:UIControlStateNormal];
button.backgroundColor=[UIColor clearColor];
[button setTitleColor:[UIColor colorWithRed:0.3 green:0.1 blue:0.4 alpha:1.0] forState:UIControlStateNormal];
[self.view addSubview:btn];
现在是边境:

[[button layer] setBorderWidth:2.0f];
[[button layer] setBorderColor:[UIColor greenColor].CGColor];

最简单的方法是为按钮创建图像资源

图像将有边框和清晰的中间


然后将图像用作按钮图像。

最简单的方法是为按钮创建图像资源

图像将有边框和清晰的中间


然后使用该图像作为按钮图像。

我可以推荐您看一看。这是一个超级可定制的UIControl,它复制了UIButton,并在外观方面提供了惊人的多功能性。它在控制状态之间也有一些很好的动画

它带有一些内置样式,但您可以完全根据自己的喜好自定义按钮


我和这个项目没有任何关系,我只是把它用在我自己的一个项目上,我很喜欢:)

我可以推荐你看看吗。这是一个超级可定制的UIControl,它复制了UIButton,并在外观方面提供了惊人的多功能性。它在控制状态之间也有一些很好的动画

它带有一些内置样式,但您可以完全根据自己的喜好自定义按钮


我和这个项目没有任何关系,我只是把它用在我自己的一个项目上,我很喜欢:)

我支持它。创建一个图像,并使用
ResizeableImageWithCapInsets:
方法创建scale9网格图像。当然,拉伸图像是一种方法。+1。截图中使用的图像实际上不是透明的。我支持这一点。创建一个图像,并使用
ResizeableImageWithCapInsets:
方法创建scale9网格图像。当然,拉伸图像是一种方法。+1。截图中使用的图像实际上不是透明的。