iOS知识点总结(一)

2016-11-04  本文已影响0人  cuptea

iOS需要学习的内容

UI

多线程网络

HTML5

实用技术


UIView的常见是属性

@property(nonatomic,readOnly) UIView *superView;
@property(nonatomic,readOnly,copy) NSArray *subviews;
@property(nonatomic)NSInteger tag
@property(nonatomic)CGAffineTransform transform
 - (void)addSubview: (UIView *)view;
 - (void)removeFromSuperView;
 - (UIView *)viewWithTag:(NSInteger)tag;
@property(nonatomic) CGRect frame;
@property(nonatomic) CGRect bounds;
@property(nonatomic) CGPoint center;

UI控件概览

什么是UIImageView

什么是UILabel

什么是按钮

按钮的设置

UIButton的状态

设置按钮的背景图片

按钮的样式

UIButton *btn = [UIButton buttonWithType: UIButtonTypeCustom];
UIButtonTypeCustom:无类型,按钮的内容需要自定义
UIButtonTypeDetailDiscloure
UIButtonTypeInfoLight
UIButtonTypeInfoDark
UIButtonTypeContactAdd

UIButton的常见设置

 -(void)setTitle:(NSString *)title forState:(UIControlState *)state;
 -(void)setTitleColor:(UIColor *)color forState:(UIControlState *)state;
 -(void)setImage:(UIImage *)image forState:(UIControlState *)state;
 -(void)setBackgroundImage:(UIImage *)image forState:(UIControlState *)state;
 btn.titleLabel.font = [UIFont  systemFontOfSize:13];
 -(NSString *)titleForState:(UIControlState)state;
 -(UIColor *)titleColorForState:(UIControlState)state;
 -(UIImage *)imageForState:(UIControlState)state;
 -(UIImage *)backgroundImageForState:(UIControlState)state;

代码创建按钮

UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]
[btn setBackgroundImage:[UIImage imageNamed:"btn_01"] forState:UIControlStateNormal]
[btn setTitle:"点我啊" forState:UIControlStateNormal]
[btn setTitleColor:[UIColor redColor] forState:UIControlStateNormal]

九宫格计算思路

plist文件

1.获得plist文件的全路径
 NSString *path = [[NSBundle MainBundle] pathForResource:@"shops" ofType:@"plist"]
 2.加载plist文件
 self.shops = [NSArray arrayWithContentOfFile:path];

用模型取代字典的好处

 -(instancetype)initWithDict(NSDictionary *)dict;
 +(instancetype)xxxWithDict(NSDcitionary *)dict;

view的封装

简单的MVC

xib和storyboard的对比

xib的加载

NSArray *views = [[NSBundle MainBundle] loadNibNamed:@"xib name" owner:nil, options: nil]
UINib *nib = [UINib nibWithNibName:@"" bundle: nil]
NSArray *view = [nib instantiateWithOwner:nil options: nil]

使用xib自定义view

+ (instancetype)shopView
{
    return [[[NSBundle MainBundle] loadNibNamed:@"" owner:nil options: nil] lastObject];
}

UIImage

UIImage *image = [UIImage imageNamed:@""];

UILabel

  - @property(nonatomic,copy) NSString *text;
  - @property(nonatomic,retain) UIFont *font;
  - @property(nonatomic,retain) UIColor *textColor;
  - @property(nonaotomic) NSTextAlignMent textAlignMent;

UIFont

+(UIFont *)systemFontOfSize:(CGFloat)fontSize;//系统默认字体
+(UIFont *)boldSystemFontOfSize:(CGFloat)fontSize;//粗体
+(UIFont *)italicSystemFontOfSize:(CGFloat)fontSize;//斜体

UIButton/UIImageView/UILabel的选择

上一篇下一篇

猜你喜欢

热点阅读