#pragma mark - UIView// frame设置需要有中间值CGRectframe = bigView.frame;
frame.size.width*=2;
frame.size.height*=2;
bigView.frame= frame;// 圆角bigView.layer.cornerRadius=150;// 角度设为frame.width/height则是个圆bigView.clipsToBounds=YES;// 边框bigView.layer.borderWidth=2;
bigView.layer.borderColor= [[UIColorblackColor] CGColor];// 设置背景图片self.view.backgroundColor= [UIColorcolorWithPatternImage:[UIImageimageNamed:@"Default"]];/*
//相对父视图的坐标
@property(nonatomic) CGRect frame;
//相对于自己内容的坐标
@property(nonatomic) CGRect bounds;
//父视图
@property(nonatomic,readonly) UIView *superview;
//所有的子视图
@property(nonatomic,readonly,copy) NSArray *subviews;
//内容模式(填充一边位等比例模式)
@property(nonatomic) UIViewContentMode contentMode; // default UIViewContentModeScaleToFill
//在最上层添加一个视图
- (void)addSubview:(UIView *)view;
//在指定层面插入一个视图(如果层级越界,就相当于add)
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;
//在某个视图是下级插入一个新视图
- (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview;
//在某个视图的上级插入一个新视图
- (void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview;
//从父视图中移除(自杀)
- (void)removeFromSuperview;
//修改2个视图的层级
- (void)exchangeSubviewAtIndex:(NSInteger)index1 withSubviewAtIndex:(NSInteger)index2;
//将某个视图移到最上层
- (void)bringSubviewToFront:(UIView *)view;
//将某个视力移到最底层
- (void)sendSubviewToBack:(UIView *)view;
//判断一个视图是否是别外一个视图的子视图(如果是同一个视图也会返回yes)
- (BOOL)isDescendantOfView:(UIView *)view;
//通过tag找view
- (UIView *)viewWithTag:(NSInteger)tag;
*/#pragma mark - UILabel/*
//设置文字
@property(nonatomic,copy) NSString *text;
//文字颜色
@property(nonatomic,retain) UIColor *textColor;
//阴影颜色
@property(nonatomic,retain) UIColor *shadowColor;
//阴影坐标
@property(nonatomic) CGSize shadowOffset;
//将label大小调整为单行展示文字所需要的大小
- (void)sizeToFit;
//对齐方式
@property(nonatomic) NSTextAlignment textAlignment;
//换行方式省略号位置
@property(nonatomic) NSLineBreakMode lineBreakMode;
//行数,默认是1,设为0后自动换行
@property(nonatomic) NSInteger numberOfLines;
//字体
@property(nonatomic,retain) UIFont *font;
*/// 不能自动换行,但能增加长度[self.labelsizeToFit];//使用固定字体label.font= [UIFontfontWithName:@"Zapfino"size:20];//系统默认字体label.font= [UIFontsystemFontOfSize:20];//系统默认字体加黑label.font= [UIFontboldSystemFontOfSize:20];//系统默认字体斜体label.font= [UIFontitalicSystemFontOfSize:20];#pragma mark - UIButton// btn的类型,除了custom和system,另外4个都自带大小和外观UIButton*btn = [UIButtonbuttonWithType:UIButtonTypeInfoDark];// 设置文字垂直和水平的对齐方式btn.titleLabel.font= [UIFontsystemFontOfSize:15];
btn.contentVerticalAlignment= UIControlContentVerticalAlignmentBottom;
btn.contentHorizontalAlignment= UIControlContentHorizontalAlignmentLeft;// 当btn接收到TouchUpInside这个事件时,会给self发送btnClick这个消息// 事件-消息机制[btn addTarget:selfaction:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
网友评论