如何使一个半圆形(顶角圆角)texview边框? [英] How to make a half rounded (Top corner rounded) texview with border?

查看:108
本文介绍了如何使一个半圆形(顶角圆角)texview边框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用borderwidth和borderColor制作半圆形(顶部圆角)textview或tableview?

How to make a half rounded (Top corner rounded) textview or tableview with the borderwidth and borderColor?

推荐答案

这不是完美的,但你可以从这里工作:

This isn't perfect, but you can work from this:

#import <QuartzCore/CoreAnimation.h>

(还链接到项目中的QuartzCore.framework),然后...

(and also link to QuartzCore.framework in your project), then..

self.textView.layer.borderColor = [UIColor redColor].CGColor;
self.textView.layer.borderWidth = 4.0f;

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.textView.bounds 
                                               byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
                                                     cornerRadii:CGSizeMake(7.0, 7.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.textView.bounds;
maskLayer.path = maskPath.CGPath;
self.textView.layer.mask = maskLayer;
[maskLayer release];

这篇关于如何使一个半圆形(顶角圆角)texview边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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