ios中设置UIButton圆角,添加边框

//例如:
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(50,50,100,40);
button.backgroundColor = [UIColor blueColor];
//关键语句
button.layer.cornerRadius = 2.0;//2.0是圆角的弧度,根据需求自己更改
button.layer.borderColor = [UIColor blackColor];//设置边框颜色
button.layer.borderWidth = 1.0f;//设置边框颜色

原文地址:https://www.cnblogs.com/liuzhi20101016/p/11695686.html

时间: 2024-08-03 04:02:16

ios中设置UIButton圆角,添加边框的相关文章

【转】iOS中设置导航栏标题的字体颜色和大小

原文网址:http://www.360doc.com/content/15/0417/11/20919452_463847404.shtml iOS中设置导航栏标题的字体颜色和大小,有需要的朋友可以参考下. 在平时开发项目的时候,难免会遇到修改导航栏字体大小和颜色的需求,一般使用自定义视图的方法,其实还存在一种方法. 方法一:(自定义视图的方法,一般人也会采用这样的方式) 就是在导航向上添加一个titleView,可以使用一个label,再设置label的背景颜色透明,字体什么的设置就很简单了.

iOS中如何优雅的添加圆角和边框?

因为项目需要,整理了下圆角和边框辅助类.想起前几天标哥还在微博里问圆角在tableView里卡顿的问题,想着去炫耀下.去到标哥的博客,发现已经有一定程度解决,给出开源库并且在推广,迭代了好几个版本了.. 圆角这东西被无数性能追求者津津乐道,无数小白们高山仰止. 至于圆角的几种实现方案,设置cornerRadius.加maskLayer.直接加镂空图.内存异步裁剪等等,网络上一搜一大把,这里就不再重复了.这里有两点要提醒下,纹理裁剪才是off-screen rendering的原因,而不是设置圆角

iOS开发-- 设置UIButton的文字显示位置、字体的大小、字体的颜色

btn.frame = CGRectMake(x, y, width, height); [btn setTitle: @"search" forState: UIControlStateNormal]; //设置按钮上的自体的大小 //[btn setFont: [UIFont systemFontSize: 14.0]];    //这种可以用来设置字体的大小,但是可能会在将来的SDK版本中去除改方法 //应该使用 btn.titleLabel.font = [UIFont sys

iOS开发--设置UIButton

1.设置title 1 [btn setTitle: @"search" forState: UIControlStateNormal]; 2.设置字体 1 //[btn setFont: [UIFont systemFontSize: 14.0]]; //这种可以用来设置字体的大小,但是可能会被移除 2 //应该使用 3 btn.titleLabel.font = [UIFont systemFontOfSize: 14.0]; 3.Title对齐 有些时候我们想让UIButton的

iOS中设置backBarButtonItem的title和action

一. 设置title 在需要显示该返回键的前一个Controller中设置: 1: navigationItem.backBarButtonItem = UIBarButtonItem(title: "注销", style: UIBarButtonItemStyle.Plain, target: nil, action: nil) .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: co

iOS中UIKit——UIButton设置边框

UIButton *testButton = [UIButton buttonWithType:UIButtonTypeSystem]; [testButton setFrame:CGRectMake(self.view.frame.size.width/2, self.view.frame.size.height/2, 100, 100)]; [testButton setTitle:@"获取屏幕尺寸" forState:UIControlStateNormal]; [testBut

iOS 图片设置为圆角矩形,圆形等

有的时候需要将图片现实为圆形 比如头像等 以下面的图片为例 我们按照正常的方式添加后效果如下 UIImageView *userIconImageV=[[UIImageView alloc]initWithFrame:CGRectMake(30, 120, 188, 188)]; [self.view addSubview:userIconImageV]; userIconImageV.image=[UIImage imageNamed:@"icon_girl.jpg"]; 此时需要用

iOS中设置导航栏标题的字体颜色和大小

在平时开发项目的时候,难免会遇到修改导航栏字体大小和颜色的需求,一般使用自定义视图的方法,其实还存在一种方法. 方法一:(自定义视图的方法,一般人也会采用这样的方式) 就是在导航向上添加一个titleView,可以使用一个label,再设置label的背景颜色透明,字体什么的设置就很简单了. //自定义标题视图 UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 44)]; titleLabel.b

ios中tableview的移动添加删除

// // MJViewController.m // UITableView-编辑模式 // // Created by mj on 13-4-11. // Copyright (c) 2013年 itcast. All rights reserved. // #import "MJViewController.h" @interface MJViewController () { // 当前的编辑模式 UITableViewCellEditingStyle _editingStyl