iOS layer.borderWidth

标签 ios uiview layer

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];

图像在 View 上,但边界线是透明的・・・ 请告诉我如何解决这个问题。

最佳答案

尝试使用:

image.clipsToBounds = YES;

关于iOS layer.borderWidth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26229085/

相关文章:

html - 分层 div 排序

javascript - Titanium - 在 iOS 上使用带数字键盘的 secure_text_input createAlertDialog?

iPhone - 将有效广告移出屏幕

ios - 如何扩大 MPVolumeView 路由按钮区域?

ios - 带有 LiveFrost LFGlassView 的 UIView 动画

jquery - 脱离控制但保留 map 上的图层

iOS UITableViewController 即使在顶部稍微滚动一下也会显示 UIRefreshControl

ios - 添加标签栏 Controller 时如何防止 subview 被切断?

ios - 继承 MKAnnotationView 并从 initWithFrame : overloads 调用 init 时无限循环

c++ - 从 PSD 文件构建层复合