当前位置:网站首页>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 .
边栏推荐
猜你喜欢
Fiddler download and installation
Node 内存溢出及V8垃圾回收机制
Docker configuring MySQL Cluster
【荧光字效果】
B站这个视频我是跪着看完的
Development to testing: a six-year road to automation starting from 0
R language ggplot2 visualization: align the legend title to the middle of the legend box in ggplot2 (default left alignment, align legend title to middle of legend)
服务器内存故障预测居然可以这样做!
CSV data file settings of JMeter configuration components
Search module use case writing
随机推荐
编写一个在bash / shell 和 PowerShell中均可运行的脚本
Azkaban【基础知识 01】核心概念+特点+Web界面+架构+Job类型(一篇即可入门Azkaban工作流调度系统)
MFC handy notes
Logical architecture of MySQL
2022年中科磐云——服务器内部信息获取 解析flag
2019 ICPC Asia Yinchuan Regional(水题题解)
Azkaban [basic knowledge 01] core concepts + features +web interface + Architecture +job type (you can get started with Azkaban workflow scheduling system in one article)
Docker configuring MySQL Cluster
Unstoppable, pure domestic PCs have been in place, and the monopoly of the U.S. software and hardware system has been officially broken
asp. Net using redis cache (2)
Keeping alive to realize MySQL automatic failover
Malloc failed to allocate space and did not return null
asp. Net using redis cache
Xiaobai makes a wave of deep copy and shallow copy
Sublime install plug-ins
解释一下自动装箱和自动拆箱?
Basic knowledge of website design
Fiddler download and installation
antd TreeSelect获取父节点的值
【信息系统项目管理师】初见高项系列精华汇总