[[CAGradientLayer alloc] init]; gradientLayer0.frame = btn.bounds; // 创建渐变色数组,需要转换为CGColor颜色...UIColor colorWithRed:255.0f/255.0f green:217.0f/255.0f blue:8.0f/255.0f alpha:1.0f].CGColor]; // 设置颜色变化点...,取值范围 0.0~1.0 gradientLayer0.locations = @[@0, @1]; // 设置渐变颜色方向,左上点为(0,0), 右下点为(1,1)...CGPointMake(1, 1)]; [btn.layer insertSublayer:gradientLayer0 atIndex:0];//注意 问题:设置渐变后,发现Button上的字体不显示...,想着设置方法在layer加载后,测试发现还是不行,把背景颜色的透明度改为0,发现背景色覆盖住字体。
好,开讲了: 在讲之前,我们得先明白他的属性和一些方法 1.属性: NSFontAttributeName 设置字体属性,默认值:字体:Helvetica(Neue...) 字号:12 NSForegroundColorAttributeNam 设置字体颜色,取值为 UIColor对象,默认值为黑色 NSBackgroundColorAttributeName...设置字体所在区域背景颜色,取值为 UIColor对象,默认值为nil, 透明色 NSLigatureAttributeName 设置连体属性,取值为NSNumber...,不是字体颜色,取值为 UIColor 对象 NSShadowAttributeName 设置阴影属性,取值为 NSShadow 对象 NSTextEffectAttributeName...NSParagraphStyleAttributeName 段落格式 NSForegroundColorAttributeName 字体颜色 NSBackgroundColorAttributeName
当设置image时图片不会变形,并且可以放大按钮的点击范围。所以这里的❌号选择设置UIButton的image,而不是backgroundImage。 3....textfield样式选择 另外登陆按钮需要设置Type为Custom,如果是System当我们按下的时候会自动做出处理如下图,并且会自动将字体渲染成蓝色 ?...SystemButton 设置为Custom就会在高亮时显示我们设置的背景图片,并且不会渲染字体颜色。...NSForegroundColorAttributeName 字体大小 NSFontAttributeName 下划线 NSUnderlineStyleAttributeName 背景颜色 NSBackgroundColorAttributeName...:second]; // 3 - 图片后部分 NSAttributedString *third = [[NSAttributedString alloc] initWithString:@"哈哈哈"
UIButton 的全面解析 建议收藏,用到的时候来这里一查就都明白了 //初始化Button 不用alloca init 的方法 用便利构造器初始化 UIButton *button = [UIButton...[button setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; //设置标题字体的大小 button.titleLabel.font...UI_APPEARANCE_SELECTOR; // default is nil 设置button 某个状态下的富文本标题 - (void)setAttributedTitle:(nullable NSAttributedString...nullable UIImage *)backgroundImageForState:(UIControlState)state; 返回button 某个状态下的富文本标题 - (nullable NSAttributedString...strong) UIImage *currentBackgroundImage; 获取按钮当前标题富文本 @property(nullable, nonatomic,readonly,strong) NSAttributedString
NSAttributedStringKey.font : UIFont.systemFont(ofSize: 16) //设置字体的颜色 NSAttributedStringKey.foregroundColor...]; [attributedString appendAttributedString:attr0]; 设置字体颜色 NSString *str1 = @"\n设置字体颜色\n"; NSDictionary...:attr1]; 设置字体背景颜色 NSString *str2 = @"设置字体背景颜色\n"; NSDictionary *dictAttr2 = @{NSBackgroundColorAttributeName...设置中间部分颜色可以使用 NSForegroundColorAttributeName 属性来进行 */ NSString *str6 = @"设置笔画宽度和填充颜色\n"; NSDictionary...textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange, 在该方法中,返回 YES,则会打开URL地址,返回 NO则不会
UIButton控件是应用界面中常用的一个控件,用法总结: 一、初始化 UIButton的初始化一般使用其类方法,+ (id)buttonWithType:(UIButtonType)buttonType...state; //设置标题和显示当前标题的按钮状态 - (void)setTitleColor:(UIColor *)color forState:(UIControlState)state; //设置标题颜色和显示当前颜色的按钮状态... - (void)setTitleShadowColor:(UIColor *)color forState:(UIControlState)state; //设置标题阴影颜色及显示时的状态 - (...imageForState:(UIControlState)state; - (UIImage *)backgroundImageForState:(UIControlState)state; - (NSAttributedString...(nonatomic,readonly,retain) UIImage *currentBackgroundImage; @property(nonatomic,readonly,retain) NSAttributedString
_model.replayView.backgroundColor = CellRow_Cor; //回复 UIButton...* replyBtn = [UIButton buttonWithType:0]; replyBtn.backgroundColor = [UIColor clearColor... _tableHeight.constant = 0; _replyTable.tableFooterView = nil; } - (void)makeReply:(UIButton... [self requestData:NO andBtn:replyBtn]; } } -(void)changeMoreShowText:(BOOL)isFirstPage andBtn:(UIButton...关于更多短视频系统功能的介绍可以关注我们的账号,我们会持续更新关于短视频功能介绍。
背景 按照往年新系统发布的时间规律,新的系统预计在9月20日左右发布,目前beta版本已经更新到beta6。...,导航栏颜色设置没有作用,呈现是白色,字体颜色也没有生效,呈现黑色,查看导航栏特性API:UINavigationBarAppearance后发现,iOS15navigationBar的相关属性设置要通过实例...UINavigationBarAppearance来实现,UINavigationBarAppearance是iOS13更新的API,应该有人已经在用,我们的应用兼容iOS10以上,对于导航栏的设置还没有使用...UITabbar tabbar的问题和navigationBar的问题属于同一类,tabbar背景颜色设置失效,字体设置失效,阴影设置失效问题 旧代码 ...... self.tabBar.backgroundImage...结尾 目前看iOS15适配工作量较小,后续发现新的适配内容我也会同步更新。
不是 UIFont lary.fontSize = 12.f;//字体的大小 lary.alignmentMode = kCAAlignmentCenter;//字体的对齐方式...lary.position = CGPointMake(160, 410); lary.foregroundColor =[UIColor redColor].CGColor;//字体的颜色...:14]}; NSAttributedString *attr0 = [[NSAttributedString alloc]initWithString:str0 attributes:dictAttr0...]; [attributedString appendAttributedString:attr0]; //设置字体颜色NSString *str1 = @"\n设置字体颜色\n"; NSDictionary...*dictAttr1 = @{NSForegroundColorAttributeName:[UIColor purpleColor]}; NSAttributedString *attr1 = [[
项目需求就是类似于实现富文本功能,可以换行,左右对齐,修改字体颜色等,选择这个的原因不光因为它可以实现以上功能,他还可以把输入好的文字转换成html。...直接上代码如下: NSString *htmlString =self.model.buyKnow; NSAttributedString *attrStr = [[NSAttributedString...= [UIFont systemFontOfSize:titleFont]; _buyRuleLabel.textColor = titleColor; 我的项目中需要在拿到标签后,颜色...,字体为显示做改变,我一直改变的是富文本希望在此基础上实现。...的默认字体颜色的问题了!
myLabel.backgroundColor = UIColor.red // 设置背景颜色 myLabel.textColor = UIColor .yellow...//设置字体颜色 myLabel.frame = CGRect.init(x: 100, y: 100, width: 180, height: 50) //设置frame...myLabel.textAlignment = NSTextAlignment.center //设置字体居中显示 myLabel.shadowColor = UIColor.black...�图1 NSAttributedString 富文本 我们还经常使用 Label 的一个属性是NSAttributedString 我们看一下这个在Swift里面怎么使用 ****当设置NSAttributedString...UIFont.systemFont(ofSize: 12), range: NSMakeRange(0,2)) //设置字体颜色
灵活使用NSAttributedString可以更轻松的创建出内容复杂的标签。需要注意一点:如果一个label设置了这个属性,那它其他的设置都将失效。...NSString *)str attributes:(NSDictionary *)attrs; //通过自身对象初始化 //- (instancetype)initWithAttributedString:(NSAttributedString...addAttribute:(NSString *)name value:(id)value range:(NSRange)range; 字典的键值对应如下: //kCTFontAttributeName 这个键是字体的名称... 必须传入CTFont对象 //kCTKernAttributeName 这个键设置字体间距 传入必须是数字对象 默认为0 //kCTLigatureAttributeName 这个键设置连字方式 必须传入...CFNumber对象 //kCTParagraphStyleAttributeName 段落对其方式 //kCTForegroundColorAttributeName 字体颜色 必须传入CGColor
0x00FF0000, 当应用程序标志时 UIControlStateReserved = 0xFF000000 为内部框架预留,可以不管他 }; 注意: 默认情况下,当按钮高亮的情况下,图像的颜色会被画深一点...是否在dealloc中对UIButton对象进行release操作,取决于UIButton初始化的方式。...文字的显示位置,字体的大小 今天遇到个很简单的几个问题,关于UIButton的,以前没有很注意,就是设置它的文字的显示位置,字体的大小。...//设置按钮上的自体的大小 //[btn setFont: [UIFont systemFontSize: 14.0]]; //这种可以用来设置字体的大小,但是可能会在将来的SDK版本中去除改方法...设置UIButton上字体的颜色设置UIButton上字体的颜色,不是用: [btn.titleLabel setTextColor:[UIColorblackColor]]; btn.titleLabel.textColor
注意:你不需要自己创建CTRun,Core Text将根据NSAttributedString的属性来自动创建CTRun。...每个CTRun对象对应不同的属性,正因此,你可以自由的控制字体、颜色、字间距等等信息。...必须是CFNumberRef 默认为1,可取0,1,2 const CFStringRefkCTForegroundColorAttributeName; //字体颜色属性 必须是CGColor对象,...,必须先将字体高为空心,否则设置颜色是没有效果的。...不管后续对context上绘制什么都不会影响真正得屏幕。
你可以完全控制位置、布局、类似文本大小和颜色这样的属性,而 Core Text 将帮你完善其它的东西——类似文本换行、字体呈现等等。...,默认值:字体:Helvetica(Neue) 字号:12 NSForegroundColorAttributeNam 设置字体颜色,取值为 UIColor对象,默认值为黑色 ...NSBackgroundColorAttributeName 设置字体所在区域背景颜色,取值为 UIColor对象,默认值为nil, 透明色 NSLigatureAttributeName...通常你需要创建NSTextStorage的子类来在文本改变时进行文本显示样式的更新。...文本视图它自己并不会做任何绘制;它仅仅提供一个供其它类绘制的区域。作为视图层级机构中唯一的组件,第二个目的是处理所有的用户交互。
Swift-Button的常用 func setButton() { // 创建一个类型为contactAdd的按钮 let button:UIButton = UIButton(type...buttonImage, for: UIControlState.normal) button.adjustsImageWhenHighlighted = false //使触摸模式下按钮也不会变暗...(半透明) button.adjustsImageWhenDisabled = false //使禁用模式下按钮也不会变暗(半透明) // button的处理事件 //...let attributeString = NSMutableAttributedString(string:"welcome to hangge.com") //从文本0开始6个字符字体..., range: NSMakeRange(0,6)) //设置字体颜色 attributeString.addAttribute
textV.font = [UIFont systemFontOfSize:SMALL_FONT]; # 设置右侧的滑动条样式 indicatorStyle # 滚动条的样式,基本只是设置颜色...,总共3个颜色,默认是黑色的,此处修改为白色的。...attributedText 实现的 _textV.attributedText = [[NSAttributedString alloc] initWithString:_textV.text..._textV.attributedText = [[NSAttributedString alloc] initWithString:_textV.text attributes:attributes]...; } 小结 整个效果中, UITextView的字体间距设置和 右侧滚动条一直保持显示状态是关键点。
7.统一收起键盘 8.导入自定义字体库 9.动态方法的动态执行 10.isKindOfClass和isMemberOfClass的区别 11.Label字体大小 12.为UIView某个角添加圆角 13...自己键盘打出的 % 汉字形式下的还是会报警告,并且不会显示出来.把上文的粘贴过去使用吧!...view.exclusiveTouch = YES; // 一个一个设置太麻烦了,可以全局设置 [[UIView appearance] setExclusiveTouch:YES]; // 或者只设置button [[UIButton...// 设置某个键盘颜色 textField.keyboardAppearance = UIKeyboardAppearanceAlert; // 设置工程中所有键盘颜色 [[UITextField...self.navigationController.navigationBar.shadowImage = [UIImage new]; self.navigationController.navigationBar.translucent = YES; 小结 后续会持续更新
UITextField四周的圆角 //需要导入框架QuartzCore.framework,并且在当前类中引用#import textField.layer.cornerRadius = 5.0 1.1.2 边框颜色...self.layer.borderColor = [[UIColor colorWithRed:213.0/255 green:213.0/255 blue:213.0/255 alpha:1.0] CGColor]; //边框颜色... *)sender { sender.backgroundColor = [UIColor greenColor]; } 2, 通过把颜色转换为UIImage来作为按钮不同状态下的背景图片...UIControlStateNormal]; //设置button的title button.titleLabel.font = [UIFont systemFontOfSize: 16]; //title字体大小...button.titleLabel.textAlignment= NSTextAlignmentCenter; //设置title的字体居中 [button setTitleColor: [UIColor
接下来,简单介绍一个我在实际开发中抽取出来的工具类 - MNKit MNButton 业务开发中,UIButton控件应该算最常用的控件之一了,而且它的属性设置还贼麻烦,很多个都是要用 [ set...的常见创建方式,设置按钮的标题、字体大小、颜色、背景色、点击事件、添加到父控件等等,基本上每个属性都是要通过[ ] 设置,最麻烦的是经常要通过forState:UIControlStateXXX设置状态...控件如果登场率如果不能排在第一,那么比它更常见的非UILabel莫属了,和UIButton一样,UILabel很常见,又经常有许多属性需要设置 - 字体大小、颜色、内容等等 //快速设置内容,文字颜色,...字体大小,父控件 [MNLabel mn_labelWithTitle:@"test-label1" font:[UIFont systemFontOfSize...SVProgressHUDMaskTypeClear - 不可交互,界面颜色不变 提示框如何只显示文字,不显示图片 。
领取专属 10元无门槛券
手把手带您无忧上云