【UIKit-124-3】#import <UIKit/UIView.h>

来源:互联网 发布:搜狐大数据中心 知乎 编辑:程序博客网 时间:2024/05/12 08:42


【视图渲染】

@interface UIView(UIViewRendering)


- (void)drawRect:(CGRect)rect;// 重绘


- (void)setNeedsDisplay;// 标记需要展示

- (void)setNeedsDisplayInRect:(CGRect)rect;// 展示



【裁剪】

@property(nonatomic)                BOOL              clipsToBounds;              // 父视图,对于超出自身范围的子视图进行裁剪 (默认NO)

- (void)viewDidLoad {    [super viewDidLoad];        redView = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];    redView.backgroundColor = [UIColor redColor];    [self.view addSubview:redView];        greenView = [[UIView alloc]initWithFrame:CGRectMake(50, 50, 100, 100)];    greenView.backgroundColor = [UIColor greenColor];    [redView addSubview:greenView];     }-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{    redView.clipsToBounds = YES;}


【一般属性】

@property(nonatomic,copy)           UIColor          *backgroundColor; // 背景

@property(nonatomic)                CGFloat           alpha;                   // 透明度

@property(nonatomic,getter=isOpaque)BOOL              opaque;        // 默认不透明,不计算透明时的重叠复杂计算。(只在drawRect中使用?)

@property(nonatomic)                BOOL              clearsContextBeforeDrawing; // 默认YES,绘制前,清空

@property(nonatomic,getter=isHidden)BOOL              hidden;                     // 隐藏,包括子视图





【填充方式】

@property(nonatomic)                UIViewContentMode contentMode;                // 填充方式,一般是imgView

    

    UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 300, 150, 150)];    imgView.image = [UIImage imageNamed:@"dadajie_chenjie"];    imgView.backgroundColor = [UIColor redColor];    [self.view addSubview:imgView];        imgView.contentMode = UIViewContentModeRedraw;        /*     typedef NS_ENUM(NSInteger, UIViewContentMode) {     UIViewContentModeScaleToFill,          imgView比例,填充图片     UIViewContentModeScaleAspectFit,       图片比例,填充imgView(不满处透明)     UIViewContentModeScaleAspectFill,      图片比例,填充imgView(不满处白色)     UIViewContentModeRedraw,               与第一个很像,(setNeedsDisplay?)          //下面的图片都是原来大小,对其方式与imgView比较     UIViewContentModeCenter,     UIViewContentModeTop,     UIViewContentModeBottom,     UIViewContentModeLeft,     UIViewContentModeRight,     UIViewContentModeTopLeft,     UIViewContentModeTopRight,     UIViewContentModeBottomLeft,     UIViewContentModeBottomRight,     };     */





【tintColor】

// 与系统有关的一些颜色的修改。待研究。

@property(nonatomic,retain) UIColor *tintColorNS_AVAILABLE_IOS(7_0);

@property(nonatomic)UIViewTintAdjustmentMode tintAdjustmentModeNS_AVAILABLE_IOS(7_0);

- (void)tintColorDidChangeNS_AVAILABLE_IOS(7_0);

    /*

     typedef NS_ENUM(NSInteger, UIViewTintAdjustmentMode) {

     UIViewTintAdjustmentModeAutomatic,

     

     UIViewTintAdjustmentModeNormal,

     UIViewTintAdjustmentModeDimmed,

     };

     

     */



@end


0 0
原创粉丝点击