//
// UIScrollView+AddItem.m
// ProjectCate
//
// Created by apple on 15/12/23.
// Copyright © 2015年 apple. All rights reserved.
//
#import "UIScrollView+AddItem.h"
#import <objc/runtime.h>
static char NameLabelKey;
@interface UIScrollView ()
@property (nonatomic,assign) UILabel * nameLabel;
@end
@implementation UIScrollView (AddItem)
- (UILabel *)nameLabel {
return objc_getAssociatedObject(self, &NameLabelKey);
}
- (void)setNameLabel:(UILabel *)label {
[self willChangeValueForKey:@"NameLabelKey"];
objc_setAssociatedObject(self, &NameLabelKey,
label,
OBJC_ASSOCIATION_ASSIGN);
[self didChangeValueForKey:@"NameLabelKey"];
}
- (void)addLabel {
UILabel * label = [[UILabel alloc]initWithFrame:self.bounds];
label.text = @"加油";
[self addSubview:label];
self.nameLabel = label;
}
@end