当前位置:网站首页>Set view dynamic picture
Set view dynamic picture
2022-07-26 09:50:00 【~ light boat ~】
Set view dynamic pictures
This article just implements a simple function , according to YYKit Realization .
Create a new project first , Open the input with the terminal vim Podfile( The premise is that your computer can be used pod Managing third parties ) take YYkit use cocopod Integrate , Okay , The preparatory work has been completed , Next, I'm going to write .
Create a new class MineHeaderView, stay .h Introduction in #import
@property (nonatomic, strong) YYAnimatedImageView *headerImgView;// Head portrait
.m In file :
When not used xib The system automatically uses this method :
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
[self.headerImgView setImageWithURL:[NSURL URLWithString:@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1503377311744&di=a784e64d1cce362c663f3480b8465961&imgtype=0&src=http%3A%2F%2Fww2.sinaimg.cn%2Flarge%2F85cccab3gw1etdit7s3nzg2074074twy.jpg"] placeholder:[UIImage imageWithColor:[UIColor grayColor]]];
}
return self;
}
To write headerImgView Lazy loading
- (YYAnimatedImageView *)headerImgView
{
if (!_headerImgView) {
_headerImgView = [YYAnimatedImageView new];
_headerImgView.contentMode = UIViewContentModeScaleToFill;
_headerImgView.userInteractionEnabled = YES;
_headerImgView.layer.cornerRadius = 90/2;
_headerImgView.layer.masksToBounds = YES;
[self addSubview:_headerImgView];
[_headerImgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(90);
make.centerX.centerY.mas_equalTo(self);
}];
}
return _headerImgView;
}
It's used in this masonry So in pouring YYKit when , take Masonry Import together , In this case MineHeaderView This class completes , The next step is to use .
stay ViewController Introduction in #import “MineHeaderView.h”
to headerView A statement
@property (nonatomic, strong) MineHeaderView *headerView;// Head view
establish UI
- (void)createUI
{
self.headerView = [[MineHeaderView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 260)];
self.headerView.backgroundColor = [UIColor redColor];
[self.view addSubview:self.headerView];
}
Call this method to achieve .
边栏推荐
- 阿里云技术专家郝晨栋:云上可观测能力——问题的发现与定位实践
- Phpexcel export Emoji symbol error
- Sqoop【付诸实践 02】Sqoop1最新版 全库导入 + 数据过滤 + 字段类型支持 说明及举例代码(query参数及字段类型强制转换)
- [MySQL database] a collection of basic MySQL operations - the basis of seeing (adding, deleting, modifying, and querying)
- [datawhale] [machine learning] Diabetes genetic risk detection challenge
- Double authentication of server and client
- MySQL的逻辑架构
- Keeping alive to realize MySQL automatic failover
- Node memory overflow and V8 garbage collection mechanism
- copyTo
猜你喜欢
开发转测试:从0开始的6年自动化之路...
Node 内存溢出及V8垃圾回收机制
在Blazor 中自定义权限验证
服务器内存故障预测居然可以这样做!
Registration module use case writing
Login module use case writing
解决npm -v突然失效 无反应
Xiaobai makes a wave of deep copy and shallow copy
QT handy notes (III) use qtcharts to draw a line chart in VS
Due to fierce competition in the new market, China Mobile was forced to launch a restrictive ultra-low price 5g package
随机推荐
Flutter Event 派发
MFC handy notes
解释一下自动装箱和自动拆箱?
POJ 1012 Joseph
Sublime install plug-ins
EOJ 2020 1月月赛 E数的变换
CSV data file settings of JMeter configuration components
Applet record
Gauss elimination
Spolicy request case
Azkaban【基础知识 01】核心概念+特点+Web界面+架构+Job类型(一篇即可入门Azkaban工作流调度系统)
Show default image when wechat applet image cannot be displayed
js 表格自动循环滚动,鼠标移入暂停
2020-12-29
The use of MySQL in nodejs
[MySQL database] a collection of basic MySQL operations - the basis of seeing (adding, deleting, modifying, and querying)
高斯消元的应用
在Blazor 中自定义权限验证
IIS website configuration
Learning notes: what are the common array APIs that change the original array or do not change the original array?