仅向带有 Quartzcore/层的 UIView 添加顶部边框? [英] Add just a top border to an UIView with Quartzcore/layer?
本文介绍了仅向带有 Quartzcore/层的 UIView 添加顶部边框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在 UIView 的顶部添加边框,如果可以,请问如何操作?
Is it possible to add a border just on top of a UIView, if so, how please?
推荐答案
我已经找到了适合我的解决方案,技巧如下:
i've find solution for me, here's the tricks :
CGSize mainViewSize = self.view.bounds.size;
CGFloat borderWidth = 1;
UIColor *borderColor = [UIColor colorWithRed:37.0/255 green:38.0/255 blue:39.0/255 alpha:1.0];
UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, mainViewSize.width, borderWidth)];
topView.opaque = YES;
topView.backgroundColor = borderColor;
topView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
[self.view addSubview:topView];
这篇关于仅向带有 Quartzcore/层的 UIView 添加顶部边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文