//
// MultilineTextField.h
//
// Created by Yuriy Gaytrov on 18.05.12.
// Copyright (c) 2012 Pure Snow re:search. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
//****************************************************************
//
//
//
//****************************************************************
@interface MultilineTextField : UITextView
//****************************************************************
//
//
//
//****************************************************************
@end
Рамка вокруг UITextView
Вообщем идея проста до безобразия - делаем свой собственный класс наследуемый от UITextView и заменяем у него функцию перерисовки:
.h
Код:
Код:
//
// MultilineTextField.m
//
// Created by Yuriy Gaytrov on 18.05.12.
// Copyright (c) 2012 Pure Snow re:search. All rights reserved.
//
#import "MultilineTextField.h"
//****************************************************************
//
//
//
//****************************************************************
@implementation MultilineTextField
//****************************************************************
//
//
//
//****************************************************************
- (void) drawRect:(CGRect)rect
{
//
CGContextRef context = UIGraphicsGetCurrentContext();
//
CGContextBeginPath(context);
CGContextSetFillColorWithColor(context, self.superview.backgroundColor.CGColor);
CGContextAddRect(context, rect);
CGContextFillPath(context);
//
CGContextSaveGState(context);
//
CGContextBeginPath(context);
CGContextAddArc(context, 7, 7, 7, M_PI, M_PI+M_PI/2, 0);
CGContextAddArc(context, rect.size.width-7, 7, 7, M_PI+M_PI/2, 0, 0);
CGContextAddArc(context, rect.size.width-7, rect.size.height-7, 7, 0, M_PI/2, 0);
CGContextAddArc(context, 7, rect.size.height-7, 7, M_PI/2, M_PI, 0);
CGContextClip(context);
//
CGFloat borderLocations[2] = { 0.00, 1.00 };
CGFloat borderComponents[8] = { 0.55, 0.55, 0.55, 1.00, 0.85, 0.85, 0.85, 1.00 };
//
CGColorSpaceRef borderSpace = CGColorSpaceCreateDeviceRGB();
CGGradientRef borderGradient = CGGradientCreateWithColorComponents(borderSpace, borderComponents, borderLocations, 2);
CGContextDrawLinearGradient(context, borderGradient, CGPointMake(0, 0), CGPointMake(0,rect.size.height), kCGGradientDrawsBeforeStartLocation);
//
CGColorSpaceRelease(borderSpace);
CGGradientRelease(borderGradient);
//
CGContextRestoreGState(context);
//
CGContextSaveGState(context);
//
CGContextBeginPath(context);
CGContextAddArc(context, 8, 8, 7, M_PI, M_PI+M_PI/2, 0);
CGContextAddArc(context, rect.size.width-8, 8, 7, M_PI+M_PI/2, 0, 0);
CGContextAddArc(context, rect.size.width-8, rect.size.height-8, 7, 0, M_PI/2, 0);
CGContextAddArc(context, 8, rect.size.height-8, 7, M_PI/2, M_PI, 0);
CGContextClip(context);
//
CGFloat innerLocations[3] = { 0.00, 3.50/rect.size.height, 1.00 };
CGFloat innerComponents[12] = { 0.55, 0.55, 0.55, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00 };
//
CGColorSpaceRef innerSpace = CGColorSpaceCreateDeviceRGB();
CGGradientRef innerGradient = CGGradientCreateWithColorComponents(innerSpace, innerComponents, innerLocations, 3);
CGContextDrawLinearGradient(context, innerGradient, CGPointMake(0, 0), CGPointMake(0,rect.size.height), kCGGradientDrawsBeforeStartLocation);
//
CGColorSpaceRelease(innerSpace);
CGGradientRelease(innerGradient);
//
CGContextRestoreGState(context);
//
[super drawRect:rect];
}
//****************************************************************
//
//
//
//****************************************************************
@end
// MultilineTextField.m
//
// Created by Yuriy Gaytrov on 18.05.12.
// Copyright (c) 2012 Pure Snow re:search. All rights reserved.
//
#import "MultilineTextField.h"
//****************************************************************
//
//
//
//****************************************************************
@implementation MultilineTextField
//****************************************************************
//
//
//
//****************************************************************
- (void) drawRect:(CGRect)rect
{
//
CGContextRef context = UIGraphicsGetCurrentContext();
//
CGContextBeginPath(context);
CGContextSetFillColorWithColor(context, self.superview.backgroundColor.CGColor);
CGContextAddRect(context, rect);
CGContextFillPath(context);
//
CGContextSaveGState(context);
//
CGContextBeginPath(context);
CGContextAddArc(context, 7, 7, 7, M_PI, M_PI+M_PI/2, 0);
CGContextAddArc(context, rect.size.width-7, 7, 7, M_PI+M_PI/2, 0, 0);
CGContextAddArc(context, rect.size.width-7, rect.size.height-7, 7, 0, M_PI/2, 0);
CGContextAddArc(context, 7, rect.size.height-7, 7, M_PI/2, M_PI, 0);
CGContextClip(context);
//
CGFloat borderLocations[2] = { 0.00, 1.00 };
CGFloat borderComponents[8] = { 0.55, 0.55, 0.55, 1.00, 0.85, 0.85, 0.85, 1.00 };
//
CGColorSpaceRef borderSpace = CGColorSpaceCreateDeviceRGB();
CGGradientRef borderGradient = CGGradientCreateWithColorComponents(borderSpace, borderComponents, borderLocations, 2);
CGContextDrawLinearGradient(context, borderGradient, CGPointMake(0, 0), CGPointMake(0,rect.size.height), kCGGradientDrawsBeforeStartLocation);
//
CGColorSpaceRelease(borderSpace);
CGGradientRelease(borderGradient);
//
CGContextRestoreGState(context);
//
CGContextSaveGState(context);
//
CGContextBeginPath(context);
CGContextAddArc(context, 8, 8, 7, M_PI, M_PI+M_PI/2, 0);
CGContextAddArc(context, rect.size.width-8, 8, 7, M_PI+M_PI/2, 0, 0);
CGContextAddArc(context, rect.size.width-8, rect.size.height-8, 7, 0, M_PI/2, 0);
CGContextAddArc(context, 8, rect.size.height-8, 7, M_PI/2, M_PI, 0);
CGContextClip(context);
//
CGFloat innerLocations[3] = { 0.00, 3.50/rect.size.height, 1.00 };
CGFloat innerComponents[12] = { 0.55, 0.55, 0.55, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00 };
//
CGColorSpaceRef innerSpace = CGColorSpaceCreateDeviceRGB();
CGGradientRef innerGradient = CGGradientCreateWithColorComponents(innerSpace, innerComponents, innerLocations, 3);
CGContextDrawLinearGradient(context, innerGradient, CGPointMake(0, 0), CGPointMake(0,rect.size.height), kCGGradientDrawsBeforeStartLocation);
//
CGColorSpaceRelease(innerSpace);
CGGradientRelease(innerGradient);
//
CGContextRestoreGState(context);
//
[super drawRect:rect];
}
//****************************************************************
//
//
//
//****************************************************************
@end
Код:
//****************************************************************
//
//
//
//****************************************************************
- (void) viewDidLoad
{
//
[super viewDidLoad];
//
self.comment.scrollIndicatorInsets = UIEdgeInsetsMake(3, 3, 3, 3);
}
//
//
//
//****************************************************************
- (void) viewDidLoad
{
//
[super viewDidLoad];
//
self.comment.scrollIndicatorInsets = UIEdgeInsetsMake(3, 3, 3, 3);
}