只使用Quartzcore / layer为UIView添加顶部边框? [英] Add just a top border to an UIView with Quartzcore/layer?

查看:118
本文介绍了只使用Quartzcore / layer为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 / layer为UIView添加顶部边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆