{"id":316,"date":"2015-10-12T22:49:53","date_gmt":"2015-10-12T22:49:53","guid":{"rendered":"http:\/\/strawberrycode.com\/blog\/?p=316"},"modified":"2015-10-12T22:49:53","modified_gmt":"2015-10-12T22:49:53","slug":"swift-tips-1-extra-padding-problem-on-uitextview","status":"publish","type":"post","link":"https:\/\/strawberrycode.com\/blog\/swift-tips-1-extra-padding-problem-on-uitextview\/","title":{"rendered":"Swift Tips #1: Extra padding problem on UITextView?"},"content":{"rendered":"<p>Sometimes when you integrate a design, you need things to be square, everything aligned: buttons, title, images, textView&#8230;<\/p>\n<p>But wait, what&#8217;s that extra padding on the UITextView?<\/p>\n<p><img class=\"aligncenter\" src=\"http:\/\/strawberrycode.com\/blog\/wp-content\/uploads\/2015\/10\/TextViewAnimation.gif\" alt=\"UITextView Animation\" height=\"640\" style=\"border: 1px solid #ccc\" \/><\/p>\n<p>You may have tried to print the <code>contentOffset<\/code> or <code>contentInset<\/code> without success. That&#8217;s not it. However, all your problems can be solved in one line, and here it is:<\/p>\n<pre class=\"lang:swift decode:true \">\/\/ magic line for a UITextView named textView\r\ntextView.textContainer.lineFragmentPadding = 0<\/pre>\n<p>I wouldn&#8217;t call it exactly straight forward, so this is a memo for me and tip for you :)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes when you integrate a design, you need things to be square, everything aligned: buttons, title, images, textView&#8230; But wait, what&#8217;s that extra padding on the UITextView? You may have tried to print the contentOffset or contentInset without success. That&#8217;s not it. However, all your problems can be solved in one line, and here it is: \/\/ magic line for a UITextView named textView textView.textContainer.lineFragmentPadding = 0 I wouldn&#8217;t call it exactly straight forward, so this is a memo for me and tip for you :)<\/p>\n","protected":false},"author":1,"featured_media":183,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[40,63],"tags":[17,41,65,64,66,62],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.1.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Swift Tips #1: Extra padding problem on UITextView? - StrawberryCode<\/title>\n<meta name=\"description\" content=\"Sometimes when you integrate a design, you need things to be square, aligned: buttons, title, images. But what&#039;s that extra padding on the UITextView?\" \/>\n<link rel=\"canonical\" href=\"http:\/\/strawberrycode.com\/blog\/swift-tips-1-extra-padding-problem-on-uitextview\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Swift Tips #1: Extra padding problem on UITextView? - StrawberryCode\" \/>\n<meta property=\"og:description\" content=\"Sometimes when you integrate a design, you need things to be square, aligned: buttons, title, images. But what&#039;s that extra padding on the UITextView?\" \/>\n<meta property=\"og:url\" content=\"http:\/\/strawberrycode.com\/blog\/swift-tips-1-extra-padding-problem-on-uitextview\/\" \/>\n<meta property=\"og:site_name\" content=\"StrawberryCode\" \/>\n<meta property=\"article:published_time\" content=\"2015-10-12T22:49:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/strawberrycode.com\/blog\/wp-content\/uploads\/2015\/04\/Apple_Swift_Logo-e1430073805246.png\" \/>\n\t<meta property=\"og:image:width\" content=\"200\" \/>\n\t<meta property=\"og:image:height\" content=\"200\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/strawberrycode.com\/blog\/#website\",\"url\":\"https:\/\/strawberrycode.com\/blog\/\",\"name\":\"StrawberryCode\",\"description\":\"Fruit for Thought\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/strawberrycode.com\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-GB\"},{\"@type\":\"ImageObject\",\"@id\":\"http:\/\/strawberrycode.com\/blog\/swift-tips-1-extra-padding-problem-on-uitextview\/#primaryimage\",\"inLanguage\":\"en-GB\",\"url\":\"https:\/\/strawberrycode.com\/blog\/wp-content\/uploads\/2015\/04\/Apple_Swift_Logo-e1430073805246.png\",\"contentUrl\":\"https:\/\/strawberrycode.com\/blog\/wp-content\/uploads\/2015\/04\/Apple_Swift_Logo-e1430073805246.png\",\"width\":200,\"height\":200,\"caption\":\"Apple Swift Logo\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/strawberrycode.com\/blog\/swift-tips-1-extra-padding-problem-on-uitextview\/#webpage\",\"url\":\"http:\/\/strawberrycode.com\/blog\/swift-tips-1-extra-padding-problem-on-uitextview\/\",\"name\":\"Swift Tips #1: Extra padding problem on UITextView? - StrawberryCode\",\"isPartOf\":{\"@id\":\"https:\/\/strawberrycode.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\/\/strawberrycode.com\/blog\/swift-tips-1-extra-padding-problem-on-uitextview\/#primaryimage\"},\"datePublished\":\"2015-10-12T22:49:53+00:00\",\"dateModified\":\"2015-10-12T22:49:53+00:00\",\"author\":{\"@id\":\"https:\/\/strawberrycode.com\/blog\/#\/schema\/person\/c328d959959928f47281d7a0ec779e2a\"},\"description\":\"Sometimes when you integrate a design, you need things to be square, aligned: buttons, title, images. But what's that extra padding on the UITextView?\",\"breadcrumb\":{\"@id\":\"http:\/\/strawberrycode.com\/blog\/swift-tips-1-extra-padding-problem-on-uitextview\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/strawberrycode.com\/blog\/swift-tips-1-extra-padding-problem-on-uitextview\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/strawberrycode.com\/blog\/swift-tips-1-extra-padding-problem-on-uitextview\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/strawberrycode.com\/blog\/\",\"url\":\"https:\/\/strawberrycode.com\/blog\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"http:\/\/strawberrycode.com\/blog\/swift-tips-1-extra-padding-problem-on-uitextview\/\",\"url\":\"http:\/\/strawberrycode.com\/blog\/swift-tips-1-extra-padding-problem-on-uitextview\/\",\"name\":\"Swift Tips #1: Extra padding problem on UITextView?\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/strawberrycode.com\/blog\/#\/schema\/person\/c328d959959928f47281d7a0ec779e2a\",\"name\":\"StrawberryCode\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/strawberrycode.com\/blog\/wp-json\/wp\/v2\/posts\/316"}],"collection":[{"href":"https:\/\/strawberrycode.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/strawberrycode.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/strawberrycode.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/strawberrycode.com\/blog\/wp-json\/wp\/v2\/comments?post=316"}],"version-history":[{"count":17,"href":"https:\/\/strawberrycode.com\/blog\/wp-json\/wp\/v2\/posts\/316\/revisions"}],"predecessor-version":[{"id":338,"href":"https:\/\/strawberrycode.com\/blog\/wp-json\/wp\/v2\/posts\/316\/revisions\/338"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/strawberrycode.com\/blog\/wp-json\/wp\/v2\/media\/183"}],"wp:attachment":[{"href":"https:\/\/strawberrycode.com\/blog\/wp-json\/wp\/v2\/media?parent=316"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/strawberrycode.com\/blog\/wp-json\/wp\/v2\/categories?post=316"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/strawberrycode.com\/blog\/wp-json\/wp\/v2\/tags?post=316"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}