{"id":996,"date":"2013-09-10T18:38:54","date_gmt":"2013-09-10T09:38:54","guid":{"rendered":"https:\/\/www.united-bears.co.jp\/blog\/?p=996"},"modified":"2013-09-10T18:38:54","modified_gmt":"2013-09-10T09:38:54","slug":"uitextview-%e3%81%ae%e8%a6%8b%e3%81%9f%e7%9b%ae%e3%82%92%e5%a4%89%e6%9b%b4%e3%81%99%e3%82%8b3","status":"publish","type":"post","link":"https:\/\/www.united-bears.co.jp\/blog\/archives\/996","title":{"rendered":"UITextView \u306e\u898b\u305f\u76ee\u3092\u5909\u66f4\u3059\u308b(3)"},"content":{"rendered":"<p><a href=\" https:\/\/www.united-bears.co.jp\/blog\/archives\/928\" target=\"_blank\">\u524d\u56de<\/a>\u540c\u69d8\u3001\u4eca\u56de\u3082<strong>UITextView<\/strong>\u3092<strong>UITextField<\/strong>\u306e\u89d2\u4e38\u3068\u540c\u3058\u3088\u3046\u306a\u898b\u305f\u76ee\u306b\u5909\u66f4\u3057\u3066\u307f\u308b\u3002<\/p>\n<p>\u4eca\u56de\u306f\u3001<a href=\"http:\/\/cocoadays.blogspot.jp\/2010\/06\/bezel03.html\" target=\"_blank\">\u30b3\u30b3<\/a>\u3092\u53c2\u8003\u306b<strong>UITextView<\/strong>\u306e<strong>drawRect<\/strong>\u30e1\u30bd\u30c3\u30c9\u3092\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3057\u3066\u81ea\u5206\u3067\u7d75\u3092\u63cf\u3044\u3066\u307f\u308b\u3002<\/p>\n<p><strong>#1:\u307e\u305a\u306f\u89d2\u4e38\u77e9\u5f62\u306e\u30d1\u30b9\u3092\u4f5c\u6210\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3092\u7528\u610f\u3057\u3066\u304a\u3044\u3066&#8230;<\/strong><\/p>\n<pre>\r\n- (void)addRoundRectPath:(CGContextRef)context rect:(CGRect)rect radius:(CGFloat)radius\r\n{\r\n    CGFloat minX = CGRectGetMinX(rect);\r\n    CGFloat midX = CGRectGetMidX(rect);\r\n    CGFloat maxX = CGRectGetMaxX(rect);\r\n    CGFloat minY = CGRectGetMinY(rect);\r\n    CGFloat midY = CGRectGetMidY(rect);\r\n    CGFloat maxY = CGRectGetMaxY(rect);\r\n\r\n    CGContextMoveToPoint(context, minX, midY);\r\n    CGContextAddArcToPoint(context, minX, minY, midX, minY, radius);\r\n    CGContextAddArcToPoint(context, maxX, minY, maxX, midY, radius);\r\n    CGContextAddArcToPoint(context, maxX, maxY, midX, maxY, radius);\r\n    CGContextAddArcToPoint(context, minX, maxY, minX, midY, radius);\r\n}\r\n<\/pre>\n<p><strong>#2:\u89d2\u4e38\u77e9\u5f62\u306e\u307f\u63cf\u753b\u3057\u3066\u307f\u308b&#8230;<\/strong><\/p>\n<pre>\r\n- (void)drawRect:(CGRect)rect\r\n{\r\n    CGContextRef context = UIGraphicsGetCurrentContext();\r\n    CGFloat radius = 5.0f; \/\/ \u89d2\u4e38\u306e\u534a\u5f84\r\n\r\n    [self addRoundRectPath:context rect:rect radius:radius];\r\n    [[UIColor whiteColor] setFill];\r\n    CGContextClosePath(context);\r\n    CGContextDrawPath(context, kCGPathFill);\r\n}\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.united-bears.co.jp\/blog\/wp-content\/uploads\/2013\/09\/ios_uitextview3_02.png\" alt=\"ios_uitextview3_02\" width=\"457\" height=\"138\" class=\"alignnone size-full wp-image-1002\" \/><\/p>\n<p><strong>#3:\u305d\u3057\u3066\u5f71\u306e\u307f\u63cf\u753b\u3057\u3066\u307f\u308b&#8230;<\/strong><\/p>\n<pre>\r\n- (void)drawRect:(CGRect)rect\r\n{\r\n    CGRect frame = CGRectInset([self bounds], 3, 3);\r\n    CGContextRef context = UIGraphicsGetCurrentContext();\r\n    CGFloat radius = 5.0f; \/\/ \u89d2\u4e38\u306e\u534a\u5f84\r\n\r\n    \/\/ \u5f71\u63cf\u753b\u7528\u306e\u56f3\u5f62\u3092\u4f5c\u6210\r\n    CGContextAddRect(context, [self bounds]);\r\n    [self addRoundRectPath:context rect:frame radius:radius];\r\n        \r\n    \/\/ \u5f71\u3092\u8a2d\u5b9a\r\n    CGContextSetShadow(context, CGSizeMake(2.0f, 2.0f), 2.0f);\r\n        \r\n    \/\/ \u63cf\u753b\r\n    CGContextDrawPath(context, kCGPathEOFill);\r\n}\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.united-bears.co.jp\/blog\/wp-content\/uploads\/2013\/09\/ios_uitextview3_03.png\" alt=\"ios_uitextview3_03\" width=\"436\" height=\"131\" class=\"alignnone size-full wp-image-1004\" \/><\/p>\n<p><strong>#2\u3068#3\u3092\u540c\u6642\u306b\u63cf\u753b\u3059\u308b\u3068&#8230;<\/strong><br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.united-bears.co.jp\/blog\/wp-content\/uploads\/2013\/09\/ios_uitextview3_04.png\" alt=\"ios_uitextview3_04\" width=\"436\" height=\"131\" class=\"alignnone size-full wp-image-1005\" \/><\/p>\n<p>\u5f71\u63cf\u753b\u7528\u306b\u4f5c\u6210\u3057\u305f\u56f3\u5f62\u304c\u63cf\u753b\u3055\u308c\u305f\u307e\u307e\u306a\u306e\u3067\u3001\u89d2\u4e38\u77e9\u5f62\u3067\u30af\u30ea\u30c3\u30d4\u30f3\u30b0\u3059\u308b\u51e6\u7406\u3092\u8ffd\u52a0<br \/>\n<strong>\u6700\u7d42\u7684\u306b\u306f\u3053\u3046\u306a\u3063\u305f\u3002<\/strong><\/p>\n<pre>\r\n- (void)addRoundRectPath:(CGContextRef)context rect:(CGRect)rect radius:(CGFloat)radius\r\n{\r\n    CGFloat minX = CGRectGetMinX(rect);\r\n    CGFloat midX = CGRectGetMidX(rect);\r\n    CGFloat maxX = CGRectGetMaxX(rect);\r\n    CGFloat minY = CGRectGetMinY(rect);\r\n    CGFloat midY = CGRectGetMidY(rect);\r\n    CGFloat maxY = CGRectGetMaxY(rect);\r\n\r\n    CGContextMoveToPoint(context, minX, midY);\r\n    CGContextAddArcToPoint(context, minX, minY, midX, minY, radius);\r\n    CGContextAddArcToPoint(context, maxX, minY, maxX, midY, radius);\r\n    CGContextAddArcToPoint(context, maxX, maxY, midX, maxY, radius);\r\n    CGContextAddArcToPoint(context, minX, maxY, minX, midY, radius);\r\n}\r\n\r\n- (void)drawRect:(CGRect)rect\r\n{\r\n    CGRect frame = CGRectInset([self bounds], 3, 3);\r\n    CGFloat radius = 5.0f;\r\n\r\n    CGContextRef context = UIGraphicsGetCurrentContext();\r\n    CGContextSaveGState(context);\r\n\r\n    \/\/ \u77e9\u5f62(\u89d2\u4e38)\u3067\u30af\u30ea\u30c3\u30d4\u30f3\u30b0\r\n    [self addRoundRectPath:context rect:frame radius:radius];\r\n    CGContextClip(context);\r\n    \r\n    \/\/ \u77e9\u5f62(\u89d2\u4e38)\u63cf\u753b\r\n    [self addRoundRectPath:context rect:frame radius:radius];\r\n    [[UIColor whiteColor] setFill];\r\n    CGContextClosePath(context);\r\n    CGContextDrawPath(context, kCGPathFill);\r\n\r\n    \/\/ \u5f71\u63cf\u753b\u7528\u306e\u56f3\u5f62\u3092\u4f5c\u6210\r\n    CGContextAddRect(context, [self bounds]);\r\n    [self addRoundRectPath:context rect:frame radius:radius];\r\n\r\n    \/\/ \u5f71\u3092\u8a2d\u5b9a\r\n    CGContextSetShadow(context, CGSizeMake(2.0f, 2.0f), 2.0f);\r\n\r\n    \/\/ \u63cf\u753b\r\n    CGContextDrawPath(context, kCGPathEOFill);\r\n\r\n    CGContextRestoreGState(context);\r\n}\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.united-bears.co.jp\/blog\/wp-content\/uploads\/2013\/09\/ios_uitextview3_01.png\" alt=\"ios_uitextview3_01\" width=\"436\" height=\"131\" class=\"alignnone size-full wp-image-1012\" \/><\/p>\n<p>\u591a\u5c11<strong>UITextField<\/strong>\u306e\u89d2\u4e38\u3068\u306f\u9055\u3046\u3068\u3053\u308d\u306f\u3042\u308b\u3051\u3069\u3001\u3068\u308a\u3042\u3048\u305a\u826f\u3057\u3068\u3057\u3088\u3046\uff01<\/p>\n<p>\u660e\u65e5\uff089\u670811\u65e5\uff09\u306b\u3082iOS 7\u3078\u306e\u30a2\u30c3\u30d7\u30c7\u30fc\u30bf\u304c\u914d\u5e03\u3055\u308c\u308b\u306e\u3067\u3001<br \/>\n\u4eca\u5f8c\u3001\u4f7f\u7528\u3059\u308b\u3053\u3068\u306f\u306a\u3044\u304b\u306a\u3002\u3002\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u540c\u69d8\u3001\u4eca\u56de\u3082UITextView\u3092UITextField\u306e\u89d2\u4e38\u3068\u540c\u3058\u3088\u3046\u306a\u898b\u305f\u76ee\u306b\u5909\u66f4\u3057\u3066\u307f\u308b\u3002 \u4eca\u56de\u306f\u3001\u30b3\u30b3\u3092\u53c2\u8003\u306bUITextView\u306edrawRect\u30e1\u30bd\u30c3\u30c9\u3092\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3057\u3066\u81ea\u5206\u3067\u7d75\u3092\u63cf\u3044\u3066\u307f\u308b\u3002 #1:\u307e [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,21],"tags":[],"class_list":["post-996","post","type-post","status-publish","format-standard","hentry","category-iphone","category-iphone-develop"],"_links":{"self":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts\/996","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/comments?post=996"}],"version-history":[{"count":17,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts\/996\/revisions"}],"predecessor-version":[{"id":1018,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts\/996\/revisions\/1018"}],"wp:attachment":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/media?parent=996"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/categories?post=996"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/tags?post=996"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}