我有Array.prototype.qpush = function( vals, fixed ) {
if (arguments.length) {
if (Array.isArray(vals)) {
for (var v of vals) {
this.push(v);
}
} else {
this.push(vals);
}
var _f = (typeof this.fixed != undefined) ? this.fixed : 0;
if (typeof fixed != undefined) {
_f = (Number(fixed)===fixed && fixed%1===0 ) ? fixed : _f;
}
this.fixed = _f;
if (this.fixed>0) this.splice(0, this.length - _f);
}
}
var q = new Array();
q.push(0);
q.qpush( [1, 2, 3], 10 );
q.qpush( [4] );
q.qpush( 5 );
q.qpush( [6, 7, 8, 9, 10, {k:"object"} ] );
console.log(q);
,这是我展示图片的代码:
UIImageView
要在图像周围添加圆圈,我这样做了:
callRecImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"call_accept.png"]];
[callRecImage setFrame:CGRectMake(133,top, 36, 40)];
[self.view addSubview: callRecImage];
我的图片视图是:
我的输出是:
我想在我的callRecImage.layer.cornerRadius = callRecImage.frame.size.width /2; callRecImage.layer.borderWidth = 2.0f;
callRecImage.layer.borderColor = [UIColor grayColor].CGColor; callRecImage.clipsToBounds = YES;
添加一个圈子,我已按照此链接image in circle frame iOS,但它按预期工作
我想在手机图像周围加一个大圆圈。任何形式的帮助将不胜感激。
提前致谢
答案 0 :(得分:0)
[callRecImage setFrame:CGRectMake(133,top, 36, 40)];
//Set Height and width equal
//Like
[callRecImage setFrame:CGRectMake(133,top, 40, 40)];
答案 1 :(得分:0)
每当你为同一个视图选择{*}
时,圆圈将始终小于视图矩形,因此请使用这两个解决方案中的一个。
我已经过测试,两种解决方案都处于工作状态
使用以下代码更改图片的layer.cornerRadius
并增加UIViewContentMode
框架尺寸(高度和宽度,两者应相等)
UIImageView
因此,如果您增加callRecImage.contentMode = UIViewContentModeCenter;
框架尺寸,它会将您的图片保持在中心位置,并且不会在UIImageView
UIImageView
或强>
添加一个UIImageView *callRecImage = [[UIImageView alloc] initWithFrame:CGRectMake(133, top, 60, 60)];
callRecImage.contentMode = UIViewContentModeCenter;
[callRecImage setImage:[UIImage imageNamed:@"call_accept.png"]];
callRecImage.layer.cornerRadius = callRecImage.frame.size.width /2;
callRecImage.layer.borderWidth = 2.0f;
callRecImage.layer.borderColor = [UIColor grayColor].CGColor;
callRecImage.clipsToBounds = YES;
[self.view addSubview: callRecImage];
作为UIView
的超级视图,并将UIImageView
添加到layer.cornerRadius
UIView
答案 2 :(得分:0)
使用以下代码
#import <QuartzCore/QuartzCore.h>
callRecImage.layer.masksToBounds = YES;
callRecImage.layer.cornerRadius = callRecImage.bounds.size.width/2;
callRecImage.layer.borderWidth = 2.0f;
callRecImage.layer.borderColor = [UIColor grayColor].CGColor;
答案 3 :(得分:0)
添加以下行以仅在ImageView
callRecImage.contentMode = UIViewContentModeScaleAspectFill;
答案 4 :(得分:0)
试试此代码
callRecImage.layer.backgroundColor=[[UIColor clearColor] CGColor];
callRecImage.layer.cornerRadius=20;
callRecImage.layer.borderWidth=2.0;
callRecImage.layer.masksToBounds = YES;
callRecImage.layer.borderColor=[[UIColor grayColor] CGColor]