Victor Choi

  • Home
  • Business
    • Internet
    • Market
    • Stock
  • Parent Category
    • Child Category 1
      • Sub Child Category 1
      • Sub Child Category 2
      • Sub Child Category 3
    • Child Category 2
    • Child Category 3
    • Child Category 4
  • Featured
  • Health
    • Childcare
    • Doctors
  • Home
  • Business
    • Internet
    • Market
    • Stock
  • Downloads
    • Dvd
    • Games
    • Software
      • Office
  • Parent Category
    • Child Category 1
      • Sub Child Category 1
      • Sub Child Category 2
      • Sub Child Category 3
    • Child Category 2
    • Child Category 3
    • Child Category 4
  • Featured
  • Health
    • Childcare
    • Doctors
  • Uncategorized
Showing posts with label Bottom Margin. Show all posts
Showing posts with label Bottom Margin. Show all posts

7/10/2016

How to put a padding into a UITextField ?

 2:09 PM     Bottom Margin, Margin, Padding, Top Margin, UIEdgeInsets, UIEdgeInsetsInsetRect, UITextField     No comments   

In iOS development you can put a padding into a UITextField with a code below.

First of all , you can create a customized UITextField class for giving it an inset . And then you can put a code below into the class inherited UITextField class.

let padding = UIEdgeInsets(top: 7, left: 0, bottom: 7, right: 0)

override func textRectForBounds(bounds: CGRect) -> CGRect {
    return UIEdgeInsetsInsetRect(bounds, padding)
}
override func placeholderRectForBounds(bounds: CGRect) -> CGRect {
    return UIEdgeInsetsInsetRect(bounds, padding)
}
override func editingRectForBounds(bounds: CGRect) -> CGRect {
    return UIEdgeInsetsInsetRect(bounds, padding)
}

UIEdgeInsets Type

UIEdgeInsets is defining a inset distnaces for views. You can easily customize your insets for a view with this type. Positive values will shrink the view and negative value will expand the view.

UIEdgeInsetsInsetRect Function

UIEdgeInsetsInsetRect adjusts a rectangle by the given edge insets. In this code you can adjust a rectangle for textfield’s text and etc with UIEdgeInsetsInsetRect. It receives UIEdgeInsets structure type as a parameter.

I hope that Apple provides a function or an interface that we can easily adjut insets through the interface builder.

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Older Posts Home

Search This Blog

Popular Posts

  • Git ignore vs Git exclude
  • Keynote Tutorial Character Style , How to use a character style in Keynote
  • If you can't get OAuth Token by SFSafariViewController...?
  • Bitbucket authentication error, Invalid username and password
  • OmniFocus Review Perspective action using Launch Center Pro

Blog Archive

  • ▼  2020 (2)
    • ▼  January (2)
      • Error- helm docker-registry does not have any acti...
      • How to clean up none docker images
  • ►  2019 (21)
    • ►  December (2)
    • ►  November (6)
    • ►  October (5)
    • ►  September (2)
    • ►  August (3)
    • ►  July (2)
    • ►  June (1)
  • ►  2017 (11)
    • ►  December (2)
    • ►  November (2)
    • ►  July (2)
    • ►  May (1)
    • ►  April (1)
    • ►  March (3)
  • ►  2016 (48)
    • ►  December (3)
    • ►  November (2)
    • ►  September (1)
    • ►  August (10)
    • ►  July (5)
    • ►  June (7)
    • ►  May (2)
    • ►  April (18)
Powered by Blogger.

Navigation Menu

  • Home
  • About
  • Documentation
  • Contact

Contact Us

Name

Email *

Message *

Copyright © Victor Choi | Powered by Blogger
Design by Hardeep Asrani | Blogger Theme by NewBloggerThemes.com | Distributed By Gooyaabi Templates