设置按钮(UIButton)为圆角矩形

     //设置按钮颜色

self.autoLoginCheckBox.layer.borderColor = [[UIColor redColor] CGColor];
        //设置边框宽度
        self.autoLoginCheckBox.layer.borderWidth = 1;
        //设置按钮为圆角矩形
        [self.autoLoginCheckBox.layer setMasksToBounds:YES];
        [self.autoLoginCheckBox.layer setCornerRadius:5];

时间: 2024-08-09 01:07:31

设置按钮(UIButton)为圆角矩形的相关文章

安卓如何设置控件的圆角矩形背景

当我们开发过程中需要实现控件的圆角矩形或者给背景添加边框时,最佳的办法不是生成背景图片或者添加ImageView当做边界,而是利用Shape来做. 思路就是在drawable文件夹中自定义一个美化布局,代码如下 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> &

UIButton 如何设置为圆角矩形

先上代码 //登录按钮 loginBtn=[UIButton buttonWithType:UIButtonTypeRoundedRect]; loginBtn.frame=CGRectMake(1, 199, 200, 36); [self.view addSubview:loginBtn]; [loginBtn addTarget:self action:@selector(login) forControlEvents:UIControlEventTouchUpInside]; 这样生成的

【iOS开发-57】案例改进:block动画、控件的removeFromSuperview、利用layer设置圆角矩形以及代理模式运用

接上述案例,案例改进:[iOS开发-50]利用创建新的类实现代码封装,从而不知不觉实践一个简单的MVC实验,附带个动画 在上述案例中,我们最后实现了一个动画,点击"下载"按钮变成"已下载"不可点击,然后中间出现提示框. (1)其中有一个小BUG,就是这个提示的透明度变成0之后,这个提示框并没有显示还留在内存中.需要: [tipsLabel removeFromSuperview]; (2)其次,我们可以用另一个代码实现动画,就是用block,这一次是2个block嵌

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

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

CSS中设置元素的圆角矩形

圆角矩形介绍 在CSS中通过border-radius属性可以实现元素的圆角矩形. border-radius属性值一共有4个,左上.右上.左下.右下. border-radius属性值规则如下:第一个值为左上.第二个值为右上.第三个值为左下.第四个值为右下. 假如border-radius属性值都是一致的我可以设置一个属性值即可. 圆角矩形实践 圆角矩形基本使用方式 <!DOCTYPE html> <html lang="en"> <head> &

用贝赛尔曲线把图片, 按钮, label 绘成圆 或圆角矩形

//创建圆形遮罩,把用户头像变成圆形 /* *CGPointMake(35, 35)  是绘图的中心点,  如果想把控件居中绘圆, 一般用控件的中心点,   radius 是圆半径   startAngle是圆周 圆的一周就是2*m_pi */ //    UIBezierPath* path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(35, 35) radius:35 startAngle:0 endAngle:2 * M_PI c

Android设置窗口变暗,圆角按钮以及include和merge的使用

昨天写了一个小Demo,实现了几个小功能,今天贴上来.由于这几个个Feature比较简单,所以放在一起了.先看一下效果图: 上代码: Main: package com.example.includelayoutdemo; import android.app.Activity; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; import android.view.M

IOS之UI -- 按钮UIButton的细节

*:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } a { color: #4183C4; } a.absent { color: #cc0000; } a.anchor { display: block; padding-left: 30px; margin-left: -30px; cursor: pointer; position: absolute

【Android学习笔记】圆角矩形ImageView自定义控件的实现与使用

在做安卓项目的过程中,我们总会遇到需要以圆角矩形控件来显示图标.图片或者按钮的需求,解决办法有两种,一种是在drawable下创建shape布局xml文件,另一种是自定义一个继承于ImageView的自定义控件类来实现,下面是具体的实现办法. 首先我们命名一个XCRoundRectImageView类,并继承于ImageView.代码如下: 1 import android.content.Context; 2 import android.graphics.Bitmap; 3 import a