ios开发 富文本

iOS开发 按钮富文本 今天想写个按钮的富文本,几经波折之后,完成了。 先上代码 一开始以为直接设置按钮的attributedTitle就可以了,但是执行效果却是如下图: 全部变色了,好吧,再加上一句self.serverBtn.titleLabel.attributedText = attributedStr; 这回就行了, 于是 阅读详情
富文本属性Attributes
1、NSFontAttributeName: 设置字体字号
2、NSForegroundColorAttributeName : 设置文字颜色
3、NSKernAttributeName: 设置字符间距
4、NSParagraphStyleAttributeName: 设置段落样式
样式有:lineSpacing 行间距、paragraphSpacing 段落间距、alignment 对齐方式等
5、NSBackgroundColorAttributeName: 设置背景颜色
6、NSStrokeColorAttributeName: 设置文字描边颜色
注意:如果需要使文字空心则需和NSStrokeWidthAttributeName(设置描边宽度)一起使用
7、NSStrikethroughStyleAttributeName:添加删除线
8、NSUnderlineStyleAttributeName:添加下划线
9、NSShadowAttributeName 设置阴影属性
注意:该属性单独设置不太好用,可以和NSVerticalGlyphFormAttributeName(横竖排设置)、NSObliquenessAttributeName(设置字体倾斜)、NSExpansionAttributeName(设置字体加粗)等属性一起搭配使用
10、NSBackgroundColorAttributeName :设置文字背景颜色
11、NSAttachmentAttributeName:设置文本附件

12、NSTextEffectAttributeName: 设置文本特殊效果

13、NSWritingDirectionAttributeName:设置文字方向

以上的富文本属性总结的并不是很全面,但是基本上常用的都列举出来了微笑

iOS开发之UILabel(富文本) 1、常见的属性及说明NSFontAttributeName //字体 NSParagraphStyleAttributeName //段落格式 NSForegroundColorAttributeName //字体颜色 NSBackgroundColorAttributeName //背景颜色 NSStrikethroughStyleAttributeName //删除线格式 NSUnd 阅读详情

相关推荐

iOS开发 在图片上添加文字,图片合成文字,图片上添加富文本,美图秀秀,美颜相机文字编辑

一:前言  1.0  :在图片上增加文字,是图片编辑中非常常见的需求。  1.1 :无demo说话不硬气,上github地址:https://github.com/horisea/PictureWhitening                欢迎star,你的星星是我持续创作的动力 二:上一下效果图 下面我们看一下功能: 1.首先文字的颜色是

horisea的博客 9935

iOS富文本(NSAttributedString)---尽力弄全了

把简书文章搬过来 最近浮躁,毛线都没写,不断有人关注点赞我,必须总结点干货了。项目上要加载html格式的文本,学习一下富文本相关内容。1.加载HTML标签文本因为解析的数据里面有html标签,就使用下面的代码把字符串转换成data,初始化时再用HTML类型,转换为富文本。 NSMutableAttributedString * attrStr = [[NSMutableAttributedStri

舍本逐末 2万+

iOS开发工具:【封装富文本API,采用block实现链式编程】(block 的妙用:结合block和方法的优点实现iOS的链式编程)

前言 block 的妙用:结合block和方法的优点实现iOS的链式编程 -【 完整pod 仓库源码GitHub】 主要针对段落样式NSMutableParagraphStyle和富文本NSMutableAttributedString进行封装 代码效果 xx.kn_addString(@"封装富文本API").kn_fontColor(UIColor.redColor).kn_addString(@"采用block实现链式编程").kn_fontColor(UIColor.blueColor)

专注于计算机研发知识和资讯分享 2万+

ios富文本属性

@interface ViewController ()@property (weak,nonatomic)  IBOutlet UILabel *stringLabel;@end@implementation ViewController - (void)viewDidLoad {   [super viewDidLoad];   NSString *strin

cj772728583的博客 490

calibre QRC提取寄生参数

typical将上面的文件QCI_flow里面的文件 在Cp 到当前 ,其实应该是某几个文件,但是我给忘记了 就全cp过来了 ,无影响,不过也希望大佬指正。

2202_75711937的博客 1517

腾讯文档API逆向分析:不用Selenium也能批量导出的黑科技

本文揭秘了如何通过Python逆向分析腾讯文档的隐藏API,实现无需Selenium即可批量导出在线表格的高效方法。详细解析了API调用流程、Cookie维护及异常处理技巧,相比传统方案性能提升显著,适用于大量文档导出的自动化场景。

h9j8k7l6m5n的博客 1201

7_iOS干货6_iOS 的富文本属性NSAttributedString汇总

1,NSAttributedString属性汇总       2,段落属性汇总 NSParagraphStyleAttributeName:值为NSParagraphStyle,设置段落属性,默认值为[NSParagraphStyle defaultParagraphStyle]返回的值。NSMutableParagraphStyle与NSParagraphStyle包括一下属性 ...

a_horse的博客 454

FPGA新手必看:XC7Z020最小系统搭建全攻略(附原理图解析)

本文为FPGA新手提供了XC7Z020最小系统搭建的完整实战指南。文章详细解析了电源架构、时钟复位、配置调试等关键硬件电路设计,并重点剖析了外围电路与端口引脚的连接要点及常见陷阱,帮助读者从零开始构建稳定可靠的开发平台。

weixin_29189377的博客 359

iOS 富文本~设置字体大小和颜色

//联系人:石虎 QQ:1224614774 昵称:嗡嘛呢叭咪哄 一、富文本效果图: 图1: 二、富文本实现代码: //1.初始化UILabel UILabel *introLabel = [UILabel lableFrame:CGRectZero title:nil backgroundColor:[UIColor cl

石虎 1万+

STK轨道仿真环境搭建实战:从地月系到多天体场景

本文详细介绍了STK轨道仿真环境搭建的实战指南,从基础的地月系统到复杂的多天体场景。通过逐步操作说明和实用技巧,帮助用户快速掌握STK软件的使用方法,提升轨道仿真效率,适用于航天任务设计和教学演示。

weixin_30312563的博客 397

学Simulink——控制执行场景实例:基于Simulink的智能车辆电子稳定控制(ESC)仿真

本文完成了基于 Simulink 的智能车辆电子稳定控制(ESC),实现了:✅ 构建含轮胎非线性的车辆动力学模型✅ 设计滑模横摆稳定性控制器✅ 实现四轮制动力分配逻辑✅ 验证在双移线低附着场景下的卓越稳定性✅ 为主动安全控制系统开发提供完整范式。

xiaoheshang_123的博客 528

iOS 开发 富文本

文章内容大纲 1、NSMutableAttributedString的基本使用2、NSMutableAttributedString的简易封装3、使用开源代码GOBMarkupPaser处理富文本4、UITextKit简介5、编程思想的相关思考 前言 富文本使用案例: 这里我自己也用了富文本实现了简单的却也是常用的例子: 对于最后面的¥50中划线这种设置,估计

奋斗吧灬青年的博客 644

Qt入门教程【基础控件篇】QLineEdit输入框

QLineEdit输入框

小鱼酱的博客 3261

iOS开发之NSMutableParagraphStyle富文本

在iOS开发中,常常会有一段文字显示不同的颜色和字体,或者给某几个文字加删除线或下划线行间距的需求。就需要富文本来实现。 ###一、实例化方法和使用方法 NSMutableAttributedString *detailStr = [[NSMutableAttributedString alloc] initWithString:detailString]; NSRange stringRange = NSMakeRange(0, 5); [detailStr addAttribute:NS

旭日的博客 1702

【数据集】2019年中国1km格网河网密度数据集

中国1km格网河网密度数据集

WW、forever的博客 1342

PyTorch生成式人工智能(25)——基于Transformer实现机器翻译

不同于循环神经网络 (RNN) 按顺序处理数据,Transformer 以并行的方式处理输入数据(例如句子)。这种并行处理提高了效率,但并未使其能够识别输入的顺序。为了解决这个问题,Transformer 向输入的词嵌入中添加了位置编码。这些位置编码是分配给输入序列中每个位置的独特向量,其维度与输入词嵌入对齐。本节将以英语到法语的翻译为例,通过介绍如何训练 Transformer 模型将英语句子转换为法语,深入理解 Transformer 的架构及自注意力机制的运作方式。

盼小辉丶的博客 2717

iOS 开发 富文本详解之TextKit详解

textkit结构textkit使用步骤#Mark - 1. 自定义label --class CZLabel: UILabel---四个属性 //1.属性文本存储 private lazy var textStorage = NSTextStorage() //2.负责文本字形布局对象 private lazy var layoutManager = NSLayoutManager() //3.

高级软件开发工程师--周玉的博客 2162

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

探索CJLabel:iOS开发者的富文本利器

探索CJLabel:iOS开发者的富文本利器 在移动应用开发的世界里,用户界面的美观与交互性是吸引用户的关键。特别是在iOS平台上,一个优秀的用户界面往往能够极大地提升应用的用户体验。今天,我们要介绍的是一个强大的开源项目——CJLabel,它不仅继承了UILabel的所有特性,还提供了丰富的扩展功能,让你的文本展示更加生动和互动。 项目介绍 CJLabel是一个基于UILabel的扩展库,它允许...

gitblog_00241的博客 315

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

iOS开发实战:UILabel、UIButton、UITextField富文本样式设置技巧

平台自动处理了环境配置,能实时预览效果,特别适合验证各种富文本组合表现。我测试发现生成iOS样式项目的速度比本地创建工程快很多,对于需要快速验证的场景非常实用。关键属性包括NSUnderlineStyleAttributeName(下划线)、NSStrikethroughStyleAttributeName(删除线)等。局部文字颜色通过NSForegroundColorAttributeName配合特定NSRange实现。商品标签组合样式(颜色+字体+下划线)实际开发中遇到样式需求时,推荐通过。

IronwoodPanther89的博客 917

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

ios图文详情加载html_iOS开发之富文本(图文混排)(全)

设置富文本所有的key(共21种)NSMutableAttributedString*abs = [[NSMutableAttributedString alloc] initWithString:text];1、NSFontAttributeName (value是UIFont对象): 文本大小文本大小2、NSParagraphStyleAttributeName(value是NSParagra...

weixin_33158363的博客 729

IOS开发控件视图day14:富文本

UILabel *lab = [[UILabel alloc]init]; lab.text = @"4.23%"; NSRange range=[lab13.text rangeOfString:@"%"]; lab.font = [UIFont fontWithName:@"PingFangSC-Medium" size:12]; lab.textColor = [UIColor redColor]; [self.view addSubview:lab] //富文本 NSMutableAttribute

wenyu_Saitama的博客 242

iOS开发之富文本(oc与swift两种都有)

iOS开发中常会遇到让Label的文字多样化显示,比如不同的颜色,不同的字体,这就要用到所谓的富文本,下面我已经把方法简单封了一下,建议大家放到单例中调用,swift版直接拖到最后面看        根据需求使用第一个或第二个方法 /**  *  多样性字符串处理  *  *  @param original   原始字符串  *  @

w_shuiping的博客 1784

SwiftRichString 终极指南:如何在 iOS 开发中优雅处理富文本

SwiftRichString 是一款轻量级 Swift 库,专为 iOS、macOS、tvOS 和 watchOS 设计,提供简洁的富文本处理方案。无论是基础文本样式设置、XML 标签解析,还是动态字体适配,它都能让富文本开发变得简单高效。 ## 🚀 为什么选择 SwiftRichString? 在 iOS 开发中,富文本处理往往涉及繁琐的 `NSAttributedString` 配置。

gitblog_00859的博客 686

IOS富文本+点击事件《开发日志》

效果图: - (void)protocolView:(NSString *)protocolName { NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"我已阅读并同意%@",protocolName]]; [attributedString addAttribute:N...

李小源的博客 1260

iOS开发解析富文本

在开发中经常有后台返回的富文本字符串需要iOS开发者解析,很多同学第一想到的是webview,但是webview的性能不好而且并不利于适配。有更简单的方法就是直接将富文本字符解析成iOS中的富文本,然后将富文本显示在UILabel上,这样内存消耗比较低,并且非常有利于屏幕的适配OC:NSAttributedString * a...

weixin_34248258的博客 765
上一篇: ios开发 UI高级 更新Ruby
下一篇: ios开发 UI高级 自定义表情键盘
A_StayFoolish
博客等级 码龄10年 0粉丝 47原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值