加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ClassIconImageView.m 3.21 KB
一键复制 编辑 原始数据 按行查看 历史
xiexiaolong.xxl 提交于 2024-06-18 15:06 . init
//
// ClassIconImageView.m
// xxt_xj
//
// Created by Points on 14-6-18.
// Copyright (c) 2014年 Points. All rights reserved.
//
#import "ClassIconImageView.h"
#import <QuartzCore/QuartzCore.h>
@implementation ClassIconImageView
@synthesize classIconView= classIconView;
- (id)initWithFrame:(CGRect)frame
{
if(self = [super initWithFrame:frame])
{
classIconView = [[EGOImageView alloc]initWithFrame:CGRectMake(3,3, frame.size.width-6, frame.size.height-6)];
[self addSubview:classIconView];
}
return self;
}
- (void)setNewImage:(id)url withDefaultImg:(NSString *)defaultImgage
{
[self setImage:[UIImage imageNamed:@"parent_head_boundry"]];
classIconView.layer.masksToBounds = YES;
classIconView.layer.cornerRadius = (self.frame.size.width-6)/2;
if([url isKindOfClass:[NSURL class]])
{
if([[(NSURL *)url absoluteString]rangeOfString:@"jpg"].length == 0 && [[(NSURL *)url absoluteString]rangeOfString:@"png"].length == 0)
{
[classIconView setImageForAllSDK:nil withDefaultImage:[UIImage imageNamed:defaultImgage]];
}
else
{
[classIconView setImageForAllSDK:(NSURL *)url withDefaultImage:[UIImage imageNamed:defaultImgage]];
}
}
else
{
[classIconView setImage:(UIImage *)url];
}
}
- (void)setNewImage:(id)url WithSpeWith:(int)sepWidth withDefaultImg:(NSString *)defaultImgage
{
[classIconView setFrame:CGRectMake(sepWidth,sepWidth, self.frame.size.width-sepWidth*2, self.frame.size.height-sepWidth*2)];
[self setImage:[UIImage imageNamed:@"parent_head_boundry"]];
classIconView.layer.masksToBounds = YES;
classIconView.layer.cornerRadius = (self.frame.size.width-sepWidth*2)/2;
if([url isKindOfClass:[NSURL class]] && url != nil)
{
[classIconView setImageForAllSDK:(NSURL *)url withDefaultImage:[UIImage imageNamed:defaultImgage]];
}
else if ([url isKindOfClass:[NSString class]] && url != nil)
{
[classIconView setImageForAllSDK:[NSURL URLWithString:url] withDefaultImage:[UIImage imageNamed:defaultImgage]];
}
else
{
[classIconView setImage:(UIImage *)url];
}
}
- (void)setImage:(UIImage *)img WithSpeWith:(int)sepWidth
{
[classIconView setFrame:CGRectMake(sepWidth,sepWidth, self.frame.size.width-sepWidth*2, self.frame.size.height-sepWidth*2)];
[self setImage:img];
classIconView.layer.masksToBounds = YES;
classIconView.layer.cornerRadius = (self.frame.size.width-sepWidth*2)/2;
}
- (void)setClassImage:(id)url withDefaultImg:(NSString *)defaultImgage
{
[self setImage:[UIImage imageNamed:@"head_boundrary@2x"]];
if([url isKindOfClass:[NSURL class]])
{
if([[(NSURL *)url absoluteString]rangeOfString:@"jpg"].length == 0 && [[(NSURL *)url absoluteString]rangeOfString:@"png"].length == 0)
{
[classIconView setImageForAllSDK:nil withDefaultImage:[UIImage imageNamed:defaultImgage]];
}
else
{
[classIconView setImageForAllSDK:(NSURL *)url withDefaultImage:[UIImage imageNamed:defaultImgage]];
}
}
else
{
[classIconView setImage:(UIImage *)url];
}
}
@end
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化