簡體   English   中英

iOS layer.borderWidth

[英]iOS layer.borderWidth

UIView *view = [[UIView alloc]initWithFrame:CGRectMake(100,100,100,100)];
view.backgroundColor = [UIColor redColor];
view.layer.borderWidth = 1.0;
view.layer.borderColor = [UIColor blueColor].CGColor;
UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(-8, -10, 20, 20)];
image.image = [UIImage imageNamed:@"sample"];
[view addSubview:image];

圖像在視圖中,但邊界線是透明的……・ ・請給我解決方法。

嘗試使用:

image.clipsToBounds = YES;
 image.contentMode = UIViewContentModeScaleAspectFit;

添加上面的代碼行,問題將得到解決。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM