You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
115 lines
2.8 KiB
115 lines
2.8 KiB
1 year ago
|
//
|
||
|
// imageborder.m
|
||
|
// Hateimageview
|
||
|
//
|
||
|
// Created by BiuBiu on 17/5/9.
|
||
|
// Copyright © 2017年 BiuBiu. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "Imageborder.h"
|
||
|
#define RGBA(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
|
||
|
#define RGB(r,g,b) RGBA(r,g,b,1.0f) //rgb颜色快捷定义
|
||
|
|
||
|
@implementation Imageborder{
|
||
|
CGFloat Mysize;
|
||
|
|
||
|
}
|
||
|
|
||
|
#pragma mark 初始化方法
|
||
|
-(instancetype)init{
|
||
|
return [self initWithFrame:CGRectMake(0, 0, 0, 0)];
|
||
|
}
|
||
|
|
||
|
-(instancetype)initWithFrame:(CGRect)frame{
|
||
|
self = [super initWithFrame:frame];
|
||
|
if (self) {
|
||
|
[self initData];
|
||
|
[self initView];
|
||
|
}
|
||
|
return self;
|
||
|
}
|
||
|
|
||
|
|
||
|
#pragma mark 初始化布局参数
|
||
|
-(void)initData{
|
||
|
Mysize =40;
|
||
|
}
|
||
|
|
||
|
#pragma mark 初始化布局视图
|
||
|
-(void)initView{
|
||
|
|
||
|
[self setImage:[UIImage imageNamed:@"touxiang-1"] forState:UIControlStateNormal];
|
||
|
|
||
|
self.layer.cornerRadius = self.frame.size.width/2;
|
||
|
self.layer.masksToBounds = YES;
|
||
|
|
||
|
CGFloat bianhight =Mysize/10/2;
|
||
|
self.BgView.frame = CGRectMake(self.frame.size.width/2 -Mysize/2,
|
||
|
self.frame.size.height/2 -Mysize/2,
|
||
|
Mysize,
|
||
|
Mysize) ;
|
||
|
self.BgView.layer.cornerRadius = self.BgView.frame.size.width/2;
|
||
|
self.BgView.layer.borderWidth = bianhight;
|
||
|
|
||
|
|
||
|
CGFloat ImageRadius =Mysize - Mysize/5;
|
||
|
|
||
|
self.headPortrait.frame = CGRectMake(self.frame.size.width/2 -ImageRadius/2,
|
||
|
self.frame.size.height/2 -ImageRadius/2,
|
||
|
ImageRadius,
|
||
|
ImageRadius);
|
||
|
self.headPortrait.layer.cornerRadius = _headPortrait.frame.size.width/2;
|
||
|
self.headPortrait.layer.masksToBounds = YES;
|
||
|
|
||
|
self.headPortrait.contentMode = UIViewContentModeScaleAspectFill;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
#pragma mark 组件构造
|
||
|
-(UIView*)BgView{
|
||
|
if (!_BgView) {
|
||
|
_BgView =({
|
||
|
UIView * view = [[UIView alloc]init];
|
||
|
view.backgroundColor = RGB(233, 233, 233);
|
||
|
|
||
|
CGFloat bianhight =Mysize/10/2;
|
||
|
view.layer.borderWidth = bianhight;
|
||
|
view.layer.borderColor = RGBA(164, 164, 164 ,0.6f).CGColor;
|
||
|
|
||
|
view.layer.masksToBounds = YES;
|
||
|
view;
|
||
|
});
|
||
|
[self addSubview:_BgView];
|
||
|
}
|
||
|
|
||
|
return _BgView;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
-(UIImageView*)headPortrait{
|
||
|
if (!_headPortrait) {
|
||
|
_headPortrait =({
|
||
|
UIImageView * imageview = [[UIImageView alloc]init];
|
||
|
imageview.backgroundColor = [UIColor orangeColor];
|
||
|
imageview;
|
||
|
});
|
||
|
|
||
|
[self addSubview:_headPortrait];
|
||
|
}
|
||
|
|
||
|
return _headPortrait;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
#pragma mark 进行组件绘制
|
||
|
- (void)drawRect:(CGRect)rect {
|
||
|
Mysize =rect.size.height*0.8;
|
||
|
[self initView];
|
||
|
}
|
||
|
|
||
|
|
||
|
@end
|