欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

iOS程序開發(fā)之使用PlaceholderImageView實(shí)現(xiàn)優(yōu)雅的圖片加載效果

 更新時(shí)間:2016年09月04日 11:12:28   作者:YouXianMing  
這篇文章主要介紹了ioS程序開發(fā)之使用PlaceholderImageView實(shí)現(xiàn)優(yōu)雅的圖片加載效果的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下

說明

1. PlaceHolderImageView基于SDWebImage編寫

2. 給定一個(gè)圖片的urlString,以及一個(gè)placeholderImage就可以優(yōu)雅的顯示圖片加載效果

效果

源碼

PlaceholderImageView.h/.m

//
// PlaceholderImageView.h
// SDWebImageViewPlaceHorder
//
// Created by YouXianMing on 16/9/14.
// Copyright © 2016年 YouXianMing. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface PlaceholderImageView : UIView
/**
* Picture's url string.
*/
@property (nonatomic, strong) NSString *urlString;
/**
* The placeholder's image.
*/
@property (nonatomic, strong) UIImage *placeholderImage;
/**
* Default is UIViewContentModeScaleAspectFill.
*/
@property (nonatomic) UIViewContentMode placeholderImageContentMode;
/**
* Default is UIViewContentModeScaleAspectFill.
*/
@property (nonatomic) UIViewContentMode contentImageContentMode;
@end

ImageCell.h/.m

//
// ImageCell.h
// SDWebImageViewPlaceHorder
//
// Created by YouXianMing on 16/9/14.
// Copyright © 2016年 YouXianMing. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "PlaceholderImageView.h"
@interface ImageCell : UITableViewCell
@property (nonatomic, strong) PlaceholderImageView *placeholderImageView;
@end
//
// ImageCell.m
// SDWebImageViewPlaceHorder
//
// Created by YouXianMing on 16/9/14.
// Copyright © 2016年 YouXianMing. All rights reserved.
//

#import "ImageCell.h"

@implementation ImageCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.placeholderImageView = [[PlaceholderImageView alloc] initWithFrame:CGRectMake(0, 0, 150.f, 150.f)];
self.placeholderImageView.placeholderImage = [UIImage imageNamed:@"1"];
[self addSubview:self.placeholderImageView];
}
return self;
}
@end

ViewController.m

//
// ViewController.m
// SDWebImageViewPlaceHorder
//
// Created by YouXianMing on 16/9/14.
// Copyright © 2016年 YouXianMing. All rights reserved.
//
#import "ViewController.h"
#import "UIImageView+WebCache.h"
#import "PlaceholderImageView.h"
#import "ImageCell.h"
@interface ViewController () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *pictures;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.pictures = @[@"https://pic.cnblogs.com/avatar/607542/20151017230728.png",
@"https://pic.cnblogs.com/face/607741/20140226202001.png",
@"https://pic.cnblogs.com/face/815231/20150923160245.png",
@"https://pic.cnblogs.com/face/993558/20160729092113.png",
@"https://pic.cnblogs.com/face/894202/20160217151952.png",
@"https://pic.cnblogs.com/face/968459/20160709111712.png",
@"https://pic.cnblogs.com/face/145865/20160210174306.png",
@"https://pic.cnblogs.com/face/796658/20151026090914.png",
@"https://pic.cnblogs.com/face/933887/20160629214007.png",
@"https://pic.cnblogs.com/face/125303/20130313094252.png",
@"https://pic.cnblogs.com/face/976232/20160730173456.png",
@"https://pic.cnblogs.com/face/969708/20160602120239.png",
@"https://pic.cnblogs.com/face/954541/20160705113740.png",
@"https://pic.cnblogs.com/face/799942/20150818204115.png"];
PlaceholderImageView *pImageView = [[PlaceholderImageView alloc] initWithFrame:CGRectMake(0, 0, 150.f, 150.f)];
[self.view addSubview:pImageView];
pImageView.urlString = @"https://pic.cnblogs.com/avatar/607542/20151017230728.png";
self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.rowHeight = 150.f;
[self.view addSubview:self.tableView];
[self.tableView registerClass:[ImageCell class] forCellReuseIdentifier:@"ImageCell"];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _pictures.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
ImageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ImageCell"];
cell.placeholderImageView.urlString = _pictures[indexPath.row];
return cell;
}
@end 

以上所述是小編給大家介紹的ioS程序開發(fā)之使用PlaceholderImageView實(shí)現(xiàn)優(yōu)雅的圖片加載效果,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • iOS CAEmitterLayer實(shí)現(xiàn)粒子發(fā)射動(dòng)畫效果

    iOS CAEmitterLayer實(shí)現(xiàn)粒子發(fā)射動(dòng)畫效果

    這篇文章主要為大家詳細(xì)介紹了iOS CAEmitterLayer 實(shí)現(xiàn)粒子發(fā)射動(dòng)畫效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-06-06
  • iOS中l(wèi)ebel特殊字符的自動(dòng)換行問題解決

    iOS中l(wèi)ebel特殊字符的自動(dòng)換行問題解決

    這篇文章主要給大家介紹了關(guān)于iOS中l(wèi)ebel特殊字符的實(shí)現(xiàn)不自動(dòng)換行的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)iOS具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2017-10-10
  • 利用iOS動(dòng)畫來模擬音量振動(dòng)條的實(shí)現(xiàn)

    利用iOS動(dòng)畫來模擬音量振動(dòng)條的實(shí)現(xiàn)

    本篇文章主要利用iOS動(dòng)畫來模擬音量振動(dòng)條的實(shí)現(xiàn)以及對(duì)CAReplicatorLayer的簡(jiǎn)單介紹,需要的朋友可以參考下
    2015-07-07
  • 2016 cocoapods的安裝和使用方法以及版本升級(jí)遇到的問題

    2016 cocoapods的安裝和使用方法以及版本升級(jí)遇到的問題

    CocoaPods是一個(gè)負(fù)責(zé)管理iOS項(xiàng)目中第三方開源庫的工具,通過CocoaPods,我們可以將第三方的依賴庫統(tǒng)一管理起來,配置和更新只需要通過簡(jiǎn)單的幾行命令即可完成,需要的朋友可以參考下
    2016-09-09
  • iOS獲取驗(yàn)證碼倒計(jì)時(shí)效果

    iOS獲取驗(yàn)證碼倒計(jì)時(shí)效果

    這篇文章主要為大家詳細(xì)介紹了iOS獲取驗(yàn)證碼倒計(jì)時(shí)效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • iOS Objective-c實(shí)現(xiàn)左右滑動(dòng)切換頁面

    iOS Objective-c實(shí)現(xiàn)左右滑動(dòng)切換頁面

    這篇文章主要為大家詳細(xì)介紹了iOS Objective-c實(shí)現(xiàn)左右滑動(dòng)切換頁面,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-08-08
  • 解決ios手機(jī)中input輸入框光標(biāo)過長(zhǎng)的問題

    解決ios手機(jī)中input輸入框光標(biāo)過長(zhǎng)的問題

    在項(xiàng)目中做移動(dòng)端頁面,發(fā)現(xiàn)IOS 的光標(biāo)大小很大,和安卓的完全不一樣,怎么來調(diào)整大小呢?下面小編給大家?guī)砹薸os手機(jī)中input輸入框光標(biāo)過長(zhǎng)問題的解決方法,一起看看吧
    2018-08-08
  • iOS中如何判斷中英文混合的字符長(zhǎng)度

    iOS中如何判斷中英文混合的字符長(zhǎng)度

    本文通過兩種方法給大家介紹了判斷中英文混合的字符長(zhǎng)度,非常具有參考價(jià)值,特此分享供大家學(xué)習(xí)
    2016-05-05
  • 淺析iOS中視頻播放的幾種方案

    淺析iOS中視頻播放的幾種方案

    還記得剛學(xué)iOS的時(shí)候嗎?那個(gè)時(shí)候驚訝于各種牛逼的功能只需要幾句簡(jiǎn)單的代碼就可以完成。視頻播放也是這樣,IOS中視頻播放有好幾種方式,這篇文章就給大家整理這幾種方案優(yōu)缺點(diǎn)與實(shí)現(xiàn)過程。
    2016-08-08
  • IOS 獲取APP 版本號(hào)的實(shí)例詳解

    IOS 獲取APP 版本號(hào)的實(shí)例詳解

    這篇文章主要介紹了IOS 獲取APP 版本號(hào)的實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下
    2017-07-07

最新評(píng)論