百兆宽带,稳定好用的宽带通推荐无线路由器器有什么推荐的吗

1.NSKernAttributeName: @10 调整字句 kerning 字句调整              
2.NSFontAttributeName : [UIFont systemFontOfSize:_fontSize] 设置字体    
3.NSForegroundColorAttributeName :[UIColor redColor] 设置文字颜色      
4.NSParagraphStyleAttributeName : paragraph 设置段落样式            
5.NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init];
  paragraph.alignment = NSTextAlignmentC
6.NSBackgroundColorAttributeName: [UIColor blackColor] 设置背景颜色        
7.NSStrokeColorAttributeName设置文字描边颜色,需要和NSStrokeWidthAttributeName设置描边宽度,这样就能使文字空心.
NSStrokeWidthAttributeName这个属性所对应的值是一个 NSNumber 对象(小数)。该值改变描边(相对于字体size 的百分比)。默认为 0,即不改变。正数只改变描边宽度。负数同时改变文字的描边和填充宽度。例如,对于常见的空心字,这个值通常为3.0。
同时设置了空心的两个属性,并且NSStrokeWidthAttributeName属性设置为整数,文字前景色就无效果了
8. NSStrikethroughStyleAttributeName 添加删除线,strikethrough删除线      
9. NSUnderlineStyleAttributeName 添加下划线                      
10. NSShadowAttributeName 设置阴影,单独设置不好使,必须和其他属性搭配才好使。  
和这三个任一个都好使,NSVerticalGlyphFormAttributeName,NSObliquenessAttributeName,NSExpansionAttributeName
11.NSVerticalGlyphFormAttributeName                      
该属性所对应的值是一个 NSNumber 对象(整数)。0 表示横排文本。1 表示竖排文本。在 iOS 中,总是使用横排文本,0 以外的值都未定义。
12. NSObliquenessAttributeName设置字体倾斜。Skew 斜                
13. NSExpansionAttributeName 设置文本扁平化                    
http://shijue.me/show_text/521c396a8ddf
/articles/zquENb
http://blog.csdn.net/a/article/details/9454695
/page/iOS_pptl_artile_28190.html
/Mobile/iOS/673562.html
#import "ViewController.h"
#import &CoreText/CoreText.h&
@interface ViewController ()
@implementation ViewController
- (void)viewDidLoad
[super viewDidLoad];
阅读(...) 评论()UILabel 多行文字自动换行 (自动折行)1.UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(10, 100, 300, 180)];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, 300, 150)];
label.text = @"where are you? where are you? where are you? where are you? where are you? where are you? where are you? where are you? where are you? where are you?";
//清空背景颜色
label.backgroundColor = [UIColor clearColor];
//设置字体颜色为白色
label.textColor = [UIColor whiteColor];
//文字居中显示
label.textAlignment = UITextAlignmentC
//自动折行设置
label.lineBreakMode = UILineBreakModeWordW
label.numberOfLines = 0;
在iOS中默认的UILabel中的文字在竖直方向上只能居中对齐,博主参考国外网站,从UILabel继承了一个新类,实现了居上对齐,居中对齐,居下对齐。具体如下:
#import&&UIKit/UIKit.h&&&
typedef&enum&&
&&&&VerticalAlignmentTop&=&0,&&&
&&&&VerticalAlignmentMiddle,&&
&&&&VerticalAlignmentBottom,&&
}&VerticalA&&
@interface&myUILabel&:&UILabel&&
@private&&
VerticalAlignment&_verticalA&&
@property&(nonatomic)&VerticalAlignment&verticalA&&
#import&"myUILabel.h"&&
@implementation&myUILabel&&
@synthesize&verticalAlignment&=&verticalAlignment_;&&
-&(id)initWithFrame:(CGRect)frame&{&&
&&&&if&(self&=&[super&initWithFrame:frame])&{&&
&&&&&&&&self.verticalAlignment&=&VerticalAlignmentM&&
&&&&return&&&
-&(void)setVerticalAlignment:(VerticalAlignment)verticalAlignment&{&&
&&&&verticalAlignment_&=&verticalA&&
&&&&[self&setNeedsDisplay];&&
-&(CGRect)textRectForBounds:(CGRect)bounds&limitedToNumberOfLines:(NSInteger)numberOfLines&{&&
&&&&CGRect&textRect&=&[super&textRectForBounds:bounds&limitedToNumberOfLines:numberOfLines];&&
&&&&switch&(self.verticalAlignment)&{&&
&&&&&&&&case&VerticalAlignmentTop:&&
&&&&&&&&&&&&textRect.origin.y&=&bounds.origin.y;&&
&&&&&&&&&&&&break;&&
&&&&&&&&case&VerticalAlignmentBottom:&&
&&&&&&&&&&&&textRect.origin.y&=&bounds.origin.y&+&bounds.size.height&-&textRect.size.&&
&&&&&&&&&&&&break;&&
&&&&&&&&case&VerticalAlignmentMiddle:&&
&&&&&&&&&&&&&&
&&&&&&&&default:&&
&&&&&&&&&&&&textRect.origin.y&=&bounds.origin.y&+&(bounds.size.height&-&textRect.size.height)&/&2.0;&&
&&&&return&textR&&
-(void)drawTextInRect:(CGRect)requestedRect&{&&
&&&&CGRect&actualRect&=&[self&textRectForBounds:requestedRect&limitedToNumberOfLines:self.numberOfLines];&&
&&&&[super&drawTextInRect:actualRect];&&
在使用时:
lbl_mylabel&=&[[myUILabel&alloc]&initWithFrame:CGRectMake(20,&50,&150,&600)];&&
UIColor&*color&=&[UIColor&colorWithPatternImage:[UIImage&imageNamed:@"halfTransparent.png"]];&&
lbl_mylabel.backgroundColor&=&&&
lbl_mylabel.textAlignment&=&UITextAlignmentL&&
lbl_mylabel.textColor&=&UIColor.whiteC&&
lbl_mylabel.lineBreakMode&=&UILineBreakModeWordW&&
lbl_mylabel.numberOfLines&=&0;&&
[lbl_mylabel&setVerticalAlignment:VerticalAlignmentTop];&&
[self&addSubview:lbl_mylabel];&
ios UILabel 变量名不能为title
-[UILabel copyWithZone:]: unrecognized selector sent to instance
遇到了这样一个错误,找了半天没找到是什么错误,于是,Google搜索,打开第一个链接/questions//uilabel-copywithzone-unrecognized-selector-sent-to-instance
UILabel 设置过长文本中间为省略号
&label.lineBreakMode = NSLineBreakByTruncatingMiddle;
http://blog.csdn.net/zhaopenghhhhhh/article/details/
&UILable是iPhone界面最基本的控件,主要用来显示文本信息。
&常用属性和方法有:
CGRect rect = CGRectMake(100, 200, 50, 50);
UILabel *label = [[UILabel alloc] initWithFrame:rect];
2、text //设置和读取文本内容,默认为nil
label.text = @&文本信息&; //设置内容
NSLog(@&%@&, label.text); //读取内容
3、textColor //设置文字颜色,默认为黑色
lable.textColor = [UIColor redColor];
4、font //设置字体大小,默认17
label.font = [UIFont systemFontOfSize:20]; //?一般方法
label.font = [UIFont boldSystemFontOfSize:20]; //加粗方法
label.font = [UIFont fontWithName:@"Arial" size:16]; //指定
字体的方法
//还有?一种从外部导入字体的方法。
5、textAlignment //设置标签文本对齐方式。
label.textAlignment = NSTextAlignmentC //还有
NSTextAlignmentLeft、 NSTextAlignmentRight.
6、numberOfLines //标签最多显示行数,如果为0则表示多行。
label.numberOfLines = 2;
7、enabled //只是决定了Label的绘制方式,将它设置
为NO将会使文本变暗,表示它没有激活,这时向它设置颜色值是无效的。
label.enable = NO;
8、highlighted //是否高亮显示
label.highlighted = YES;
label.highlightedTextColor = [UIColor orangeColor]; //高亮
显示时的文本颜色
9、ShadowColor //设置阴影颜色
[label setShadowColor:[UIColor blackColor]];
10、ShadowOffset //设置阴影偏移量
[label setShadowOffset:CGSizeMake(-1, -1)];
11、baselineAdjustment //如果adjustsFontSizeToFitWidth属性设
置为YES,这个属性就来控制文本基线的行为。
label.baselineAdjustment = UIBaselineAdjustmentN
UIBaselineAdjustmentAlignBaselines = 0,默认,文本最上端与中线对齐。
UIBaselineAdjustmentAlignCenters,
文本中线与label中线对齐。
UIBaselineAdjustmentNone, 文本最低端与label中线对齐。
12、Autoshrink //是否自动收缩
Fixed Font Size 默认,如果Label宽度小于文字长度时时,文字大小不自动缩放
minimumScaleFactor 设置最小收缩比例,如果Label宽度小于文字长度时,文字
进行收缩,收缩超过比例后,停止收缩。
minimumFontSize 设置最小收缩字号,如果Label宽度小于文字长度时,文字字号
减小,低于设定字号后,不再减小。//6.0以后不再使用了。
label.minimumScaleFactor = 0.5;
13、adjustsLetterSpacingToFitWidth //改变字母之间的间距来适应Label大小
myLabel.adjustsLetterSpacingToFitWidth = NO;
14、 lineBreakMode //设置文字过长时的显示格式
label.lineBreakMode = NSLineBreakByCharW以字符为显示单位显
示,后面部分省略不显示。
label.lineBreakMode = NSLineBreakByC剪切与文本宽度相同的内
容长度,后半部分被删除。
label.lineBreakMode = NSLineBreakByTruncatingH前面部分文字
以&&方式省略,显示尾部文字内容。
label.lineBreakMode = NSLineBreakByTruncatingM中间的内容
以&&方式省略,显示头尾的文字内容。
label.lineBreakMode = NSLineBreakByTruncatingT结尾部分的内容
以&&方式省略,显示头的文字内容。
label.lineBreakMode = NSLineBreakByWordW以单词为显示单位显
示,后面部分省略不显示。
15、 adjustsFontSizeToFitWidth //设置字体大小适应label宽度
label.adjustsFontSizeToFitWidth = YES;
16、attributedText:设置标签属性文本。
NSString *text = @"first";
NSMutableAttributedString *textLabelStr =
[[NSMutableAttributedString alloc]
initWithString:text];
[textLabelStr
setAttributes:@{NSForegroundColorAttributeName :
[UIColor lightGrayColor], NSFontAttributeName :
[UIFont systemFontOfSize:17]} range:NSMakeRange(11,
label.attributedText = textLabelS
17、竖排文字显示每个文字加一个换行符,这是最方便和简单的实现方式。
label.text = @"请\n竖\n直\n方\n向\n排\n列";
label.numberOfLines = [label.text length];
18、计算UIlabel 随字体多行后的高度
CGRect bounds = CGRectMake(0, 0, 200, 300);
heightLabel = [myLabel textRectForBounds:bounds
limitedToNumberOfLines:20]; //计算20行后的Label的Frame
NSLog(@"%f",heightLabel.size.height);
19、UILabel根据字数多少自动实现适应高度
UILabel *msgLabel = [[UILabel alloc]
initWithFrame:CGRectMake(15, 45, 0, 0)];
msgLabel.backgroundColor = [UIColor lightTextColor];
[msgLabel setNumberOfLines:0];
msgLabel.lineBreakMode = UILineBreakModeWordW
msgLabel.font = [UIFont fontWithName:@"Arial" size:12];
CGSize size = CGSizeMake(290, 1000);
msgLabel.text = @"获取到的deviceToken,我们可以通过webservice服务提
交给.net应用程序,这里我简单处理,直接打印出来,拷贝到.net应用环境中使
CGSize msgSie = [msgLabel.text sizeWithFont:fonts
constrainedToSize:size];
[msgLabel setFrame:CGRectMake(15, 45, 290, msgSie.height)];
20、渐变字体Label
UIColor *titleColor = [UIColor colorWithPatternImage:[UIImage
imageNamed:@"btn.png"]];
NSString *title = @"Setting";
UILabel *titleLabel = [[UILabel alloc]
initWithFrame:CGRectMake(0, 0, 80, 44)];
titleLabel.textColor = titleC
titleLabel.text =
titleLabel.font = [UIFont boldSystemFontOfSize:20];
titleLabel.backgroundColor = [UIColor clearColor];
[self.view addSubview:titleLabel];
[titleLabel release];
21、Label添加边框
titleLabel.layer.borderColor = [[UIColor grayColor] CGColor];
titleLabel.layer.borderWidth = 2;
阅读(...) 评论()[iOS开发] 你真的了解UIButton、UILabel 吗? | IT知识库
-& 正文阅读
[iOS开发]你真的了解UIButton、UILabel 吗?
你真的了解UIButton、UILabel 吗?
一:首先查看一下关于UIButton的定义
@class UIImage, UIFont, UIColor, UIImageView, UIL
//设置UIButton的样式
typedef NS_ENUM(NSInteger, UIButtonType) {
UIButtonTypeCustom = 0,
// 自定义,无风格
UIButtonTypeSystem NS_ENUM_AVAILABLE_IOS(7_0),
// standard system button
UIButtonTypeDetailDisclosure, //蓝色的披露按钮,可放在任何文字旁
UIButtonTypeInfoLight,
//微件(widget)使用的小圆圈信息按钮,可以放在任何文字旁
UIButtonTypeInfoDark,
//白色背景下使用的深色圆圈信息按钮
UIButtonTypeContactAdd, //蓝色加号(+)按钮,可以放在任何文字旁
UIButtonTypeRoundedRect = UIButtonTypeSystem,
// 白色圆角矩形,类似偏好设置表格单元或者地址簿卡片
NS_CLASS_AVAILABLE_IOS(2_0) @interface UIButton : UIControl &NSCoding&
+ (instancetype)buttonWithType:(UIButtonType)buttonT
@property(nonatomic)
UIEdgeInsets contentEdgeInsets UI_APPEARANCE_SELECTOR; // 默认值 UIEdgeInsetsZero 所有按钮的内容周围的矩形的内侧或者外侧的边缘
@property(nonatomic)
UIEdgeInsets titleEdgeI
// 默认值UIEdgeInsetsZero 设置文字的EdgeInsets 在按钮标题文本周围矩形的,向内或者向外的边缘
@property(nonatomic)
reversesTitleShadowWhenH // 默认值NO.当按钮高亮时,是否更改标题阴影
@property(nonatomic)
UIEdgeInsets imageEdgeI
// 默认值 UIEdgeInsetsZero 设置UIButton上的图标间距 属于按钮图片周围矩形的,向内或者向外的边缘
@property(nonatomic)
adjustsImageWhenH
// 默认值为YES.默认情况下,在按钮被禁用时,图像会被画的颜色深一些。要禁用此功能,请将这个属性设置为NO:
@property(nonatomic)
adjustsImageWhenD
// 默认值为YES.默认情况下,按钮在被禁用时,图像会被画的颜色淡一些。要禁用此功能,请将这个属性设置为NO:
@property(nonatomic)
showsTouchWhenH
// 默认值为 NO. 这个属性设置为YES,可令按钮在按下时发光
@property(null_resettable, nonatomic,strong)
*tintColor NS_AVAILABLE_IOS(5_0); // The tintColor is inherited through the superview hierarchy. See UIView for more information.
//获取当前UIButton的UIButtonType 只读
@property(nonatomic,readonly) UIButtonType buttonT
//常见的设置属性效果
- (void)setTitle:(nullable NSString *)title forState:(UIControlState)
- (void)setTitleColor:(nullable UIColor *)color forState:(UIControlState)state UI_APPEARANCE_SELECTOR;
- (void)setTitleShadowColor:(nullable UIColor *)color forState:(UIControlState)state UI_APPEARANCE_SELECTOR;
- (void)setImage:(nullable UIImage *)image forState:(UIControlState)
- (void)setBackgroundImage:(nullable UIImage *)image forState:(UIControlState)state UI_APPEARANCE_SELECTOR;
- (void)setAttributedTitle:(nullable NSAttributedString *)title forState:(UIControlState)state NS_AVAILABLE_IOS(6_0); // default is nil. title is assumed to be single line
- (nullable NSString *)titleForState:(UIControlState)
- (nullable UIColor *)titleColorForState:(UIControlState)
- (nullable UIColor *)titleShadowColorForState:(UIControlState)
- (nullable UIImage *)imageForState:(UIControlState)
- (nullable UIImage *)backgroundImageForState:(UIControlState)
- (nullable NSAttributedString *)attributedTitleForState:(UIControlState)state NS_AVAILABLE_IOS(6_0);
//获取当前UIButton的一些属性值 都为只读
@property(nullable, nonatomic,readonly,strong) NSString *currentT
// normal/highlighted/selected/disabled. can return nil
@property(nonatomic,readonly,strong) UIColor
*currentTitleC
// normal/highlighted/selected/disabled. always returns non-nil. default is white(1,1)
@property(nullable, nonatomic,readonly,strong) UIColor
*currentTitleShadowC
// normal/highlighted/selected/disabled.
@property(nullable, nonatomic,readonly,strong) UIImage
// normal/highlighted/selected/disabled. can return nil
@property(nullable, nonatomic,readonly,strong) UIImage
*currentBackgroundI
// normal/highlighted/selected/disabled. can return nil
@property(nullable, nonatomic,readonly,strong) NSAttributedString *currentAttributedTitle NS_AVAILABLE_IOS(6_0);
// normal/highlighted/selected/disabled. can return nil
@property(nullable, nonatomic,readonly,strong) UILabel
*titleLabel NS_AVAILABLE_IOS(3_0);
@property(nullable, nonatomic,readonly,strong) UIImageView *imageView
NS_AVAILABLE_IOS(3_0);
//指定背景边界
- (CGRect)backgroundRectForBounds:(CGRect)
//指定内容边界
- (CGRect)contentRectForBounds:(CGRect)
//指定文字标题边界
- (CGRect)titleRectForContentRect:(CGRect)contentR
//指定按钮图像边界
- (CGRect)imageRectForContentRect:(CGRect)contentR
@endUIButton是继承于UIControl,并且也遵循NSCoding的协议;知识点1:关于UIControlState的Enum值
UIControlStateNormal&&&&&&&=&0,//常态
UIControlStateHighlighted&&=&1&&&&0,//高亮
UIControlStateDisabled&&&&&=&1&&&&1,//禁用
UIControlStateSelected&&&&&=&1&&&&2,//选中
UIControlStateApplication&&=&0x00FF0000,//当应用程序标志使用时
UIControlStateReserved&&&&&=&0xFF000000//为内部框架预留的
typedef&NSUInteger&UIControlS知识点2:contentHorizontalAlignment;可以设置UIButton文字的对齐方式,contentHorizontalAlignment并不是UIButton的属性,而是它父类UIControl的一个属性;
typedef NS_ENUM(NSInteger, UIControlContentHorizontalAlignment) {
UIControlContentHorizontalAlignmentCenter = 0,
UIControlContentHorizontalAlignmentLeft
UIControlContentHorizontalAlignmentRight
UIControlContentHorizontalAlignmentFill
};知识点3:forControlEvents参数类型
typedef&NS_OPTIONS(NSUInteger,&UIControlEvents)
UIControlEventTouchDown & & & & & & & & =&1&&&&&0,//单点触摸按下事件:用户点触屏幕,或者又有新手指落下的时候。
UIControlEventTouchDownRepeat & & &=&1&&&&&1,//多点触摸按下事件,点触计数大于1:用户按下第二、三、或第四根手指的时候。
UIControlEventTouchDragInside & & & & =&1&&&&&2,//当一次触摸在控件窗口内拖动时。
UIControlEventTouchDragOutside & & & =&1&&&&&3,//当一次触摸在控件窗口之外拖动时。
UIControlEventTouchDragEnter & & & & & =&1&&&&&4,//当一次触摸从控件窗口之外拖动到内部时
UIControlEventTouchDragExit & & & & & &&=&1&&&&&5,//当一次触摸从控件窗口内部拖动到外部时。
UIControlEventTouchUpInside & & & & & &=&1&&&&&6,//所有在控件之内触摸抬起事件
UIControlEventTouchUpOutside & & & & &=&1&&&&&7,//所有在控件之外触摸抬起事件(点触必须开始与控件内部才会发送通知)。
UIControlEventTouchCancel & & & & & & & &=&1&&&&&8,//所有触摸取消事件,即一次触摸因为放上了太多手指而被取消,或者被上锁或者电话呼叫打断。
UIControlEventValueChanged & & & & & &&=&1&&&&12,//当控件的值发生改变时,发送通知。用于滑块、分段控件、以及其他取值的控件。你可以配置滑块控件何时发送通知,在滑块被放下时发送,或者在被拖动时发送。
UIControlEventEditingDidBegin & & & & &&=&1&&&&16,//当文本控件中开始编辑时发送通知
UIControlEventEditingChanged & & & & &&=&1&&&&17,//当文本控件中的文本被改变时发送通知。
UIControlEventEditingDidEnd & & & & & & &=&1&&&&18,//当文本控件中编辑结束时发送通知。
UIControlEventEditingDidEndOnExit & &=&1&&&&19,//当文本控件内通过按下回车键(或等价行为)结束编辑时,发送通知。
UIControlEventAllTouchEvents & & & & & &&=&0x00000FFF,//通知所有触摸事件。
UIControlEventAllEditingEvents & & & & &&=&0x000F0000,//通知所有关于文本编辑的事件。
UIControlEventApplicationReserved & &=&0x0F000000,//range&available&for&application&use
UIControlEventSystemReserved & & & & &=&0xF0000000,//range&reserved&for&internal&framework&use
UIControlEventAllEvents & & & & & & & & & & &=&0xFFFFFFFF//通知所有事件
};二:首先查看一下关于UILabel 的定义
@class UIColor, UIF
NS_CLASS_AVAILABLE_IOS(2_0) @interface UILabel : UIView &NSCoding&
@property(nullable, nonatomic,copy)
// 设置文本内容
@property(null_resettable, nonatomic,strong) UIFont
// 设置文本字体,默认是系统17
@property(null_resettable, nonatomic,strong) UIColor
// 设置文本色
@property(nullable, nonatomic,strong) UIColor
// 设置文本的阴影
@property(nonatomic)
// 默认值CGSizeMake(0, -1)
@property(nonatomic)
NSTextAlignment
// 默认值 NSTextAlignmentLeft 文字位置排版
@property(nonatomic)
NSLineBreakMode
lineBreakM
// default is NSLineBreakByTruncatingTail. used for single and multiple lines of text
// 富文本属性
@property(nullable, nonatomic,copy)
NSAttributedString *attributedText NS_AVAILABLE_IOS(6_0);
// 默认值 nil
@property(nullable, nonatomic,strong)
UIColor *highlightedTextC // 默认值 nil
@property(nonatomic,getter=isHighlighted) BOOL
// 默认值 NO
@property(nonatomic,getter=isUserInteractionEnabled) BOOL userInteractionE
// 默认值为 NO 所以它没有点击事件效果
@property(nonatomic,getter=isEnabled)
// 默认值为YES.
//行数 0表示不限制
@property(nonatomic) NSInteger numberOfL
@property(nonatomic) BOOL adjustsFontSizeToFitW
// 默认值为 NO 文字的大小是否根据宽度来自动调整
@property(nonatomic) UIBaselineAdjustment baselineA // default is UIBaselineAdjustmentAlignBaselines
@property(nonatomic) CGFloat minimumScaleFactor NS_AVAILABLE_IOS(6_0); // default is 0.0
@property(nonatomic) BOOL allowsDefaultTighteningForTruncation NS_AVAILABLE_IOS(9_0); // default is NO
//重写UILabel布局
- (CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)numberOfL
- (void)drawTextInRect:(CGRect)
//这个属性是用来设置多行label的最大宽度的
//当自动布局的时候约束这个label的时候这个属性会起作用
//在自动布局添加约束中,若文本超过了指定的最大宽度的时候 文本会另起一行 从而增加了label的高度
@property(nonatomic) CGFloat preferredMaxLayoutWidth NS_AVAILABLE_IOS(6_0);
// IOS7以后就弃用
@property(nonatomic) CGFloat minimumFontSize NS_DEPRECATED_IOS(2_0, 6_0); // deprecated - use minimumScaleFactor. default is 0.0
// IOS7以后就弃用
@property(nonatomic) BOOL adjustsLetterSpacingToFitWidth NS_DEPRECATED_IOS(6_0,7_0);
@endUILabel是继承于UIView,并且也遵循NSCoding的协议;知识点1:枚举类型 默认是NSLineBreakByTruncatingTail
NSLineBreakByWordWrapping = 0, 按着一个单词来显示 不会被剪辑剩余的不会被显示
NSLineBreakByCharWrapping, & 按着一个字体来显示 不会被剪辑剩余的不会被显示
NSLineBreakByClipping, & & & & 把能显示的全显示完 剩下的直接不显示可能有的字显示一半就被剪辑
NSLineBreakByTruncatingHead, & 在那一行显示不全的话 那一行 就以 ...abcd模式来显示
NSLineBreakByTruncatingTail, & 在那一行显示不全的话 那一行 就以 abcd...模式来显示
NSLineBreakByTruncatingMiddle 在那一行显示不全的话那一行 就以 ab...cd模式来显示知识点2:textAlignment是设置label的对齐方式是一个枚举,默认是左对齐
NSTextAlignmentLeft=0& & &左对齐
NSTextAlignmentCenter=1& & 居中
NSTextAlignmentRight=2 & & 右对齐
NSTextAlignmentJustified=3 左右两边都对齐 一个段落的最后一行是natural-aligned
NSTextAlignmentNatural=4 & 显示脚本的默认对齐方式知识点3:全部NSMutableAttributedString属性
NSFontAttributeN
//字体,value是UIFont对象
NSParagraphStyleAttributeN
//绘图的风格(居中,换行模式,间距等诸多风格),value是NSParagraphStyle对象
NSForegroundColorAttributeN
// 文字颜色,value是UIFont对象
NSBackgroundColorAttributeN
// 背景色,value是UIFont
NSLigatureAttributeN
字符连体,value是NSNumber
NSKernAttributeN
// 字符间隔
NSStrikethroughStyleAttributeN
//删除线,value是NSNumber
NSUnderlineStyleAttributeN
//下划线,value是NSNumber
NSStrokeColorAttributeN
//描绘边颜色,value是UIColor
NSStrokeWidthAttributeN
//描边宽度,value是NSNumber
NSShadowAttributeN
//阴影,value是NSShadow对象
NSTextEffectAttributeN
//文字效果,value是NSString
NSAttachmentAttributeN
//附属,value是NSTextAttachment 对象
NSLinkAttributeN
//链接,value是NSURL or NSString
NSBaselineOffsetAttributeN
//基础偏移量,value是NSNumber对象
NSUnderlineColorAttributeN
//下划线颜色,value是UIColor对象
NSStrikethroughColorAttributeN
//删除线颜色,value是UIColor
NSObliquenessAttributeN
//字体倾斜
NSExpansionAttributeN
//字体扁平化
NSVerticalGlyphFormAttributeN
//垂直或者水平,value是 NSNumber,0表示水平,1垂直实例运用:
/************************************************某区域内************************************************************/
NSMutableAttributedString *string = [[NSMutableAttributedString alloc]initWithString:@"0元"];
[string setAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} range:NSMakeRange(string.length-1, 1)];
etlbl.attributedText = string;
/************************************************基本用法************************************************************/
NSString *content = @"内容太多,需要自适应才能解决问题,所以需要写这个扩展类,内容太多,需要自适应才能解决问题,所以需要写这个扩展类";
NSMutableAttributedString *string = [[NSMutableAttributedString alloc]initWithString:content];
//字体大小
[string addAttribute:NSFontAttributeName
value:[UIFont systemFontOfSize:10]
range:NSMakeRange(0, 1)];
//字体颜色
[string addAttribute:NSForegroundColorAttributeName
value:[UIColor yellowColor]
range:NSMakeRange(1, 1)];
//字体背景颜色
[string addAttribute:NSBackgroundColorAttributeName
value:[UIColor purpleColor]
range:NSMakeRange(2, 1)];
//添加下划线
[string addAttribute:NSUnderlineStyleAttributeName
value:@(NSUnderlineStyleSingle)
range:NSMakeRange(3, 1)];
//添加下划线颜色
[string addAttribute:NSUnderlineColorAttributeName
value:[UIColor redColor]
range:NSMakeRange(3, 1)];
UILabel *etlbl3 = [[UILabel alloc]initWithFrame:CGRectMake(100, 400, 200, 30)];
etlbl3.attributedText = string;
[self.view addSubview:etlbl3];知识点4:iOS的UILabel设置居上对齐,居中对齐,居下对齐在iOS中默认的UILabel中的文字在竖直方向上只能居中对齐,从UILabel继承了一个新类,实现了居上对齐,居中对齐,居下对齐。
#import &UIKit/UIKit.h&
typedef enum
VerticalAlignmentTop = 0, // default
VerticalAlignmentMiddle,
VerticalAlignmentBottom,
} VerticalA
@interface myUILabel : UILabel
VerticalAlignment _verticalA
@property (nonatomic) VerticalAlignment verticalA
#import "myUILabel.h"
@implementation myUILabel
@synthesize verticalAlignment = verticalAlignment_;
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.verticalAlignment = VerticalAlignmentM
- (void)setVerticalAlignment:(VerticalAlignment)verticalAlignment {
verticalAlignment_ = verticalA
[self setNeedsDisplay];
- (CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)numberOfLines {
CGRect textRect = [super textRectForBounds:bounds limitedToNumberOfLines:numberOfLines];
switch (self.verticalAlignment) {
case VerticalAlignmentTop:
textRect.origin.y = bounds.origin.y;
case VerticalAlignmentBottom:
textRect.origin.y = bounds.origin.y + bounds.size.height - textRect.size.
case VerticalAlignmentMiddle:
// Fall through.
textRect.origin.y = bounds.origin.y + (bounds.size.height - textRect.size.height) / 2.0;
return textR
-(void)drawTextInRect:(CGRect)requestedRect {
CGRect actualRect = [self textRectForBounds:requestedRect limitedToNumberOfLines:self.numberOfLines];
[super drawTextInRect:actualRect];
运用(实现左上的效果):
lbl_mylabel = [[myUILabel alloc] initWithFrame:CGRectMake(20, 50, 150, 600)];
UIColor *color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"halfTransparent.png"]];//使用半透明图片作为label的背景色
lbl_mylabel.backgroundColor =
lbl_mylabel.textAlignment = UITextAlignmentL
lbl_mylabel.textColor = UIColor.whiteC
lbl_mylabel.lineBreakMode = UILineBreakModeWordW
lbl_mylabel.numberOfLines = 0;
[lbl_mylabel setVerticalAlignment:VerticalAlignmentTop];
[self addSubview:lbl_mylabel]; 上面的实例就是针对下面两个方法的运用:
- (CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)numberOfL
- (void)drawTextInRect:(CGRect)
加: 20:14:11&
更: 20:14:13&
&&网站联系: qq: email:&

我要回帖

更多关于 无线路由器不稳定 的文章

 

随机推荐