3

borderwidth と borderColor を使用して、半分丸めた (上隅を丸めた) textview または tableview を作成するにはどうすればよいですか?ここに画像の説明を入力

4

3 に答える 3

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];
于 2012-06-12T11:45:56.823 に答える
0

私は以下のコードを使用すると思います

    [yourTextView.layer setBorderColor: [[UIColor redColor] CGColor]];
    [yourTextView.layer setBorderWidth: 1.0];
    [yourTextView.layer setCornerRadius:8.0f];
    [yourTextView.layer setMasksToBounds:YES];

また、yourTextView の代わりに yourTableView を使用します

于 2012-06-12T11:39:00.273 に答える