如何使用borderwidth和borderColor制作半角圆角(顶角圆角)textview或tableview? 如何制作带边框的半圆角(顶角圆角)texview?
3
A
回答
0
我想用波纹管代码
[yourTextView.layer setBorderColor: [[UIColor redColor] CGColor]];
[yourTextView.layer setBorderWidth: 1.0];
[yourTextView.layer setCornerRadius:8.0f];
[yourTextView.layer setMasksToBounds:YES];
也使用yourTableView insted的yourTextView
的+0
不,我只需要一些像素边框圆角的顶角。 – Cintu
2
这不是完美的,但你可以从这个工作:
#import <QuartzCore/CoreAnimation.h>
(也链接到您的项目QuartzCore.framework),然后..
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];
+1
我使用的是相同的代码,但仍然不完美。请参阅屏幕截图。 – Cintu
1
首先删除所有代码,将产生一个边界(厦门国际银行或layer.borderWidth),并使用下面这个方法我在一个UIView类创建:
#import "UIView+RoundedCorners.h"
@implementation UIView (RoundedCorners)
#pragma mark - Public
- (void)addBorderWithRoundedCorners:(UIRectCorner)roundedCorners radius:(CGFloat)radius color:(UIColor *)color
{
self.clipsToBounds = NO;
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:roundedCorners cornerRadii:CGSizeMake(radius, radius)];
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.frame = self.bounds;
maskLayer.path = maskPath.CGPath;
maskLayer.lineWidth = 1.0;
maskLayer.strokeColor = color.CGColor;
maskLayer.fillColor = [UIColor clearColor].CGColor;
[self.layer addSublayer:maskLayer];
}
@end
相关问题
- 1. 带边框半径的多线圆角
- 2. 带边框的Css圆角
- 3. 带圆角的Div边框
- 4. 圆角边框
- 5. 如何向圆角图像添加圆角边框(使用边框半径圆角)
- 6. Highcharts:绘图边框的圆角半径
- 7. UIImageView边和顶部圆角边框
- 8. CSS圆角边框
- 9. 如何绘制一个带有圆角半径的三角形?
- 10. 如何使圆角边框的内容也是圆角的?
- 11. CALayer内边框圆角半径
- 12. 圆角边框使用半径
- 13. 圆角圆角?
- 14. 制作带圆角的WPF组合框
- 15. 如何制作带有可选圆角和边框的UIView?
- 16. 圆形顶角
- 17. 如何用OpenCV绘制圆角矩形(带圆角的矩形)?
- 18. 没有边界圆角的圆角边框
- 19. 如何制作带圆角的div
- 20. 如何制作带圆角的TFrame?
- 21. Silverlight StackPanel里面带圆角的边框
- 22. 在IE中带边框的jQuery圆角
- 23. img带有FF边框的圆角
- 24. 圆角边框的JPanel的
- 25. UITableView的圆角边框?
- 26. wxPython中的圆角边框
- 27. 的UIButton圆角和边框
- 28. img的圆角边框
- 29. 如何制作圆角转角网格?
- 30. 绘制圆角框
请参考以下链接: HTTP://计算器。 com/questions/1824463/how-to-style-uitextview-to-like-rounded-rect-text-field – Dee
http://stackoverflow.com/a/10167334/653513 –
@Dee:OP只想绕一定角度这必须通过使用'bezierPathWithRoundedRect' –