iOS 按钮文字加划掉线
2024-09-24 18:53:34
UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(, , , )]; NSDictionary *normalTitleAttributes = @{
NSForegroundColorAttributeName: [UIColor blueColor],
NSStrikethroughStyleAttributeName: @(NSUnderlineStyleSingle)
};
NSAttributedString *normalAttributedTitle = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Button", nil) attributes:normalTitleAttributes];
[btn setAttributedTitle:normalAttributedTitle forState:UIControlStateNormal]; // Set the button's title for highlighted state.
NSDictionary *highlightedTitleAttributes = @{
NSForegroundColorAttributeName : [UIColor blueColor],
NSStrikethroughStyleAttributeName: @(NSUnderlineStyleThick)
};
NSAttributedString *highlightedAttributedTitle = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Button", nil) attributes:highlightedTitleAttributes];
[btn setAttributedTitle:highlightedAttributedTitle forState:UIControlStateHighlighted]; [btn addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:btn];
最新文章
- 【无私分享:ASP.NET CORE 项目实战(第七章)】文件操作 FileHelper
- Lucene.net站内搜索—2、Lucene.Net简介和分词
- 算法系列:Reservoir Sampling
- 实现jQuery扩展总结
- Unity3D ShaderLab 立方体图的反射遮罩
- Mac OS X下高速拷贝文件路径
- C#调用C++编写的DLL函数, 以及各种类型的参数传递 z
- EffectiveC#2--为你的常量选择readonly而不是const
- Android应用-包装脚本批量方法
- anglarjs概述
- Java对象的内存模型(一)
- Angular创建路由从主界面跳转到我们的cesium界面
- 前向传播算法(Forward propagation)与反向传播算法(Back propagation)
- Error response from daemon: --cluster-store and --cluster-advertise daemon configurations are incompatible with swarm mode
- Tesseract处理背景渐变的图片
- 记录:tf.saved_model 模块的简单使用(TensorFlow 模型存储与恢复)
- java操作mongodb(连接池)(转)
- 【转】WPF查找子控件和父控件方法
- myeclipse 与 webstrom 免解析node_modules 的方法
- Hadoop 集群配置记录小结