首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏一“技”之长

    iOS UIButton解读

    UIButton控件是应用界面中常用的一个控件,用法总结: 一、初始化 UIButton的初始化一般使用其类方法,+ (id)buttonWithType:(UIButtonType)buttonType

    89420发布于 2018-08-15
  • 来自专栏猿人谷

    UIButton使用方法汇总

    //按钮初始化类方法 UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];//这里创建一个圆角矩形的按钮 //按钮初始化实例方法 UIButton *button1=[[UIButton alloc]initWithFrame:CGRectMake(50, 300, 200, 50)]; //能够定义的button类型有以下6 是否在dealloc中对UIButton对象进行release操作,取决于UIButton初始化的方式。 如果使用 [[UIButton alloc]init]的方式,则需要主动进行release释放操作。 设置UIButton上字体的颜色设置UIButton上字体的颜色,不是用: [btn.titleLabel setTextColor:[UIColorblackColor]]; btn.titleLabel.textColor

    1.8K50发布于 2018-01-17
  • 来自专栏xx_Cc的学习总结专栏

    iOS-UIButton 全面解析UIButton 的全面解析

    UIButton 的全面解析 建议收藏,用到的时候来这里一查就都明白了 //初始化Button 不用alloca init 的方法 用便利构造器初始化 UIButton *button = [UIButton

    2.2K80发布于 2018-05-10
  • 来自专栏iOS 开发

    根据后台返回的UIButton title动态改变UIButton宽度

    #import <UIKit/UIKit.h> @interface UIButton (MutableTitle) /** * 根据添加的title 改变 button 的长度 * * @ NSString *)text textFont:(UIFont *)textFont forState:(UIControlState)UIControlState; @end #import "UIButton +MutableTitle.h" @implementation UIButton (MutableTitle) - (void)setMutableTitleWithString:(NSString maxSize lineBreakMode:NSLineBreakByCharWrapping]; } return textSize; } @end 使用时 导入头文件 #import "UIButton +MutableTitle.h" UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 40)]; button.center

    1.7K40发布于 2018-06-05
  • 来自专栏sktj

    IOS UITextField UIButton 结合

    textField.borderStyle = UITextBorderStyle.line // textField.clearButtonMode = .whileEditing let btnLeft:UIButton = UIButton(type:UIButtonType.custom) btnLeft.frame = CGRect(x:0,y:0,width:30,height:30) btnLeft.setBackgroundImage UIControlState()) textField.leftView = btnLeft textField.leftViewMode = .unlessEditing let btnRight:UIButton = UIButton(type:UIButtonType.custom) btnRight.frame = CGRect(x:0,y:0,width:30,height:30) textField.rightViewMode UITextField)-> Bool { textField.resignFirstResponder() return true } func touchupInsideBtnAction(_ btn:UIButton

    1.2K40发布于 2019-07-08
  • 来自专栏iOS小生活

    UILabel、UIImageView和UIButton

    设置无限次循环 [animationImageView startAnimating];//开始播放 //[animationImageView stopAnimating];//停止播放 UIButton 但需要实现一个有点击事件的视图的时候,而这个视图内部的布局有需要自定义,这个时候就可以自定义一个UIButton,然后通过addSubview的方式给自定义的Button添加个性化组件和布局。 之前的时候,遇到上面的需求,我都是子类化一个UIView,然后给该子类添加手势,其实只需要子类化一个UIButton即可,这样就不用自己添加手势了!

    1.1K30发布于 2019-08-12
  • 来自专栏好派笔记

    IOS UIButton使用详解

    第一、UIButton的定义     UIButton *button=[[UIButton buttonWithType:(UIButtonType); 能够定义的button类型有以下6种,  typedef

    1K00发布于 2021-10-31
  • 来自专栏iOS 开发

    UIButton扩展Block点击事件

    #import <UIKit/UIKit.h> typedef void(^ButtonBlock)(UIButton* btn); @interface UIButton (Block) /** UIControlEvents)controlEvents; @end //////////////////////////////////////////////////// #import "UIButton +Block.h" #import <objc/runtime.h> @implementation UIButton (Block) static char ActionTag; /** * = [UIColor redColor]; [self.view addSubview:testButton]; [testButton addAction:^(UIButton *btn) { NSLog(@"我被点名了"); }]; [testButton addAction:^(UIButton *btn) {

    3.4K30发布于 2018-06-05
  • 来自专栏APP自动化测试

    UIButton添加倒计时

    最近一个项目有获取手机短信跟邮箱验证码功能, 所以要加一个UIButton倒计时功能 例子代码如下: 1 //获取验证码按钮 2 - (IBAction)getButtonClick:(UIButton *)sender; 3 4 #pragma mark - 获取验证码 5 - (IBAction)getButtonClick:(UIButton *)sender 6 { 7 / mainColor countColor:countColor]; 12 } 13 14 #pragma mark - button倒计时 15 - (void)setTheCountdownButton:(UIButton

    96320发布于 2019-10-15
  • 来自专栏全栈程序员必看

    iOS_UIButton 简单操作

    UIButton 风格 typedef NS_ENUM(NSInteger, UIButtonType) { UIButtonTypeCustom = 0, UIButtonTypeRoundedRect = UIButtonTypeSystem, // Deprecated, use UIButtonTypeSystem instead }; 简单操作 UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem]; button.tag = 100; // 给 Button 加入标记 在不同的方法中使用同一个控件 从父类视图中获取button UIButton *btn = (UIButton *)[self.window viewWithTag:100]; ; // 让 Button 失效 ; } - (void) buttonAction:(UIButton *)sender { sender.backgroundColor = [UIColor redColor]

    42310编辑于 2022-07-07
  • 来自专栏日常技术分享

    ios 扩大UIButton点击范围

    先了解Hit-Test请看上一篇文章 https://www.jianshu.com/writer#/notebooks/4989829/notes/33140137 定义一个UIButton的Category UIButton+ClickRange.h import <UIKit/UIKit.h> @interface UIButton (ClickRange) /** 自定义响应边界 UIEdgeInsetsMake 3.0 例如:self.btn.hitHeightScale = 3.0; */ @property(nonatomic, assign) CGFloat hitHeightScale; @end UIButton +ClickRange.m #import "UIButton+ClickRange.h" #import <objc/runtime.h> static const char * kHitEdgeInsets kHitWidthScale = "hitWidthScale"; static const char * kHitHeightScale = "hitWidthScale"; @implementation UIButton

    2.5K21发布于 2018-09-13
  • 来自专栏ShaoYL

    iOS-UI控件之UIButton

    ---恢复内容开始--- UIButton 既可以显示图片,又可以显示文字,还能随时调整内部位置 系统自带尺寸 storyboard内部调整UIButton属性 状态 监听按钮点击事件 凡是继承自UIControl (void)setBackgroundImage:(UIImage *)image forState:(UIControlState)state UI_APPEARANCE_SELECTOR; 自定义UIButton UIButton内部有两个子控件 UILabel和UIImageView 调整控件内部子控件的frame(两种方式) 实现 titleRectForContentRect 和 imageRectForContentRect // 设置imageView的内边距(影响到imageView) @property(nonatomic) UIEdgeInsets imageEdgeInsets; 图片拉伸 UIButton

    1.2K60发布于 2018-05-11
  • 来自专栏云原生布道专栏

    【IOS开发基础系列】UIButton专题

    的使用 http://my.oschina.net/u/1781028/blog/406683 1.1.5 高亮背景色设置 UIButton设置高亮状态下的背景色【原创】 http://blog.it985 .com/11543.html     1,通过按钮的事件来设置背景色 - (void)viewDidLoad {     [super viewDidLoad];     UIButton *button1 = [[UIButton alloc]  initWithFrame: CGRectMake(50, 200, 100, 50)];     [button1 setTitle: @"button1" *button2 = [[UIButton alloc]  initWithFrame: CGRectMake(170, 200, 100, 50)];     [button2 setTitle: (UIEdgeInsets)/设置button上的文字和图片上下垂直居中对齐 http://doc.okbase.net/willingYaTou/archive/38295.html 在UIButton

    72210编辑于 2023-10-16
  • 来自专栏sktj

    IOS UIButton六种按钮

    image.png contactAdd infoLight infoDark System detailDisclosure Custom 代码创建UIButton self.btn1Test = UIButton.init(type:UIButtonType.custom) self.btn1Test?.

    92150发布于 2019-07-08
  • 来自专栏娱乐心理测试

    UIButton颜色渐变 titleLabel字体不显示

    问题:设置渐变后,发现Button上的字体不显示,想着设置方法在layer加载后,测试发现还是不行,把背景颜色的透明度改为0,发现背景色覆盖住字体。

    3.4K40发布于 2019-06-25
  • 来自专栏学海无涯

    iOS26适配指南之UIButton

    介绍 在 iOS 26 中,UIButton 迎来了两项非常实用的更新: Liquid Glass 风格配置方法 — 让按钮拥有全新的半透明折射质感,完美融入 iOS 26 的视觉系统。 适配 Liquid Glass UIButton.Configuration 增加了符合 Liquid Glass 风格的配置方法:glass()、clearGlass()、prominentGlass 代码 import UIKit class ViewController: UIViewController { let configs: [UIButton.Configuration] = { [ { // iOS26新增 var config = UIButton.Configuration.glass 代码 import UIKit class ViewController: UIViewController { let button = UIButton(frame: CGRect(x:

    1.2K10编辑于 2025-08-18
  • 来自专栏学海无涯

    iOS17适配指南之UIImageView、UIButton

    imageView.removeSymbolEffect(ofType: .variableColor.reversing) // imageView.removeAllSymbolEffects() } } UIButton import UIKit class ViewController: UIViewController { lazy var button1: UIButton = { let button = UIButton(frame: CGRect(x: 100, y: 0, width: 100, height: 60)) button.setImage(UIImage button.isSymbolAnimationEnabled = true return button }() lazy var button2: UIButton UIAction { _ in } actionHandler.image = UIImage(systemName: "plus") let button = UIButton

    1.4K20编辑于 2023-07-09
  • 来自专栏DannyHoo的专栏

    iOS中让UIButton上文字居右显示

    版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010105969/article/details/55212034

    1.4K20发布于 2018-09-13
  • 来自专栏欧阳大哥的轮子

    UIButton实现各种图文结合的效果以及原理

    iOS的UIButton是一个非常常见而且常用的控件,我们一般用他来实现某个功能的提交以及选择操作。 两个子视图;而有的人则不会用UIButton来实现图文结合的功能。 那么我们是否要放弃UIButton呢? 答案是否定的,其实UIButton本身是可以支持各种图文结合的,既然UIButton上能同时显示图片和文字,那就可以肯定的说UIButton里面本身一定有一个UIImageView和UILabel8子视图 为了方便大家的使用,我把上面的图文结合样式整理成了一个UIButton的分类方法,大家可以直接拷贝使用: 头文件: // // UIButton+ImageTitleStyle.h //

    3.6K10发布于 2018-08-22
  • 来自专栏日常技术分享

    Objective-C UIButton 自定义图片位置

    为了解决这个问题 我们写一个UIButton的Category #import <UIKit/UIKit.h> typedef NS_ENUM(NSUInteger,ButtonEdgeInsetsStyle #import "UIButton+EdgeInsets.h" #import <objc/runtime.h> @implementation UIButton (EdgeInsets) - (void ; @property (weak, nonatomic) IBOutlet UIButton *buttonBottom; @property (weak, nonatomic) IBOutlet UIButton *buttonLeft; @property (weak, nonatomic) IBOutlet UIButton *buttonRight; @property (weak, nonatomic ) IBOutlet UIButton *button4; @property (weak, nonatomic) IBOutlet UIButton *button5; @property (weak

    1K30发布于 2018-09-13
领券