{"id":395,"date":"2015-01-07T09:47:06","date_gmt":"2015-01-07T01:47:06","guid":{"rendered":"http:\/\/www.yusian.com\/blog\/?p=395"},"modified":"2016-07-14T22:44:21","modified_gmt":"2016-07-14T14:44:21","slug":"uitextfield%e8%ae%be%e7%bd%ae%e5%86%85%e8%be%b9%e8%b7%9d%e7%9a%84%e4%b8%89%e7%a7%8d%e6%96%b9%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/www.yusian.com\/blog\/project\/2015\/01\/07\/094706395.html","title":{"rendered":"UITextField\u8bbe\u7f6e\u5185\u8fb9\u8ddd\u7684\u4e09\u79cd\u65b9\u5f0f"},"content":{"rendered":"<p>1\u3001\u5229\u7528UITextField\u7684\u5c5e\u6027leftView\uff0c\u521b\u5efa\u4e00\u4e2a\u5bbd\u4e3a5\uff0c\u9ad8\u4e3a20\u7684View\u8bbe\u7f6e\u4e3aUITextField\u7684leftView\uff0c\u8fd9\u6837\u89c6\u89c9\u4e0a\u5c31\u4f1a\u67095\u50cf\u7d20\u7684\u5de6\u8fb9\u8ddd<\/p>\n<pre lang=\"objc\" line=\"1\">UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 5, 20)];\ntextField.leftView = paddingView;\ntextField.leftViewMode = UITextFieldViewModeAlways;<\/pre>\n<p>2\u3001MAC OS\u4e2d\u4ee5\u53caiOS7.0\u4ee5\u524d\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u65b9\u6cd5\u8bbe\u7f6e<\/p>\n<pre lang=\"objc\" line=\"1\">[self.yourTextField setValue:[NSNumber numberWithInt:5] forKey:@\"_paddingTop\"];\n[self.yourTextField setValue:[NSNumber numberWithInt:5] forKey:@\"_paddingLeft\"];\n[self.yourTextField setValue:[NSNumber numberWithInt:5] forKey:@\"_paddingBottom\"];\n[self.yourTextField setValue:[NSNumber numberWithInt:5] forKey:@\"_paddingRight\"];<\/pre>\n<p>3\u3001\u81ea\u5b9a\u4e49\u4e00\u4e2aTextField\uff0c\u5b9e\u73b0\u5982\u4e0b\u4e24\u4e2a\u65b9\u6cd5<\/p>\n<pre lang=\"objc\" line=\"1\">\/\/\u63a7\u5236placeHolder \u7684\u4f4d\u7f6e\uff0c\u5de6\u53f3\u7f29 8px\n- (CGRect)textRectForBounds:(CGRect)bounds\n{\n    return CGRectInset(bounds , 8 , 0 );\n}\n \n\/\/ \u63a7\u5236\u6587\u672c\u7684\u4f4d\u7f6e\uff0c\u5de6\u53f3\u7f29 8px\n- (CGRect)editingRectForBounds:(CGRect)bounds\n{\n    return CGRectInset(bounds , 8 , 0 );\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u5229\u7528UITextField\u7684\u5c5e\u6027leftView\uff0c\u521b\u5efa\u4e00\u4e2a\u5bbd\u4e3a5\uff0c\u9ad8\u4e3a20\u7684View\u8bbe\u7f6e\u4e3aUITextField\u7684leftView\uff0c\u8fd9\u6837\u89c6\u89c9\u4e0a\u5c31\u4f1a\u67095\u50cf\u7d20\u7684\u5de6\u8fb9\u8ddd UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 5, 20)]; textField.leftView = paddingView; textField.leftViewMode = UITextFieldViewModeAlways; 2\u3001MAC OS\u4e2d\u4ee5\u53caiOS7.0\u4ee5\u524d\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u65b9\u6cd5\u8bbe\u7f6e [self.yourTextField setValue:[NSNumber numberWithInt:5] forKey:@&#8221;_paddingTop&#8221;]; [self.yourTextField setValue:[NSNumber numberWithInt:5] forKey:@&#8221;_paddingLeft&#8221;]; [self.yourTextField setValue:[NSNumber numberWithInt:5] forKey:@&#8221;_paddingBottom&#8221;]; [self.yourTextField setValue:[NSNumber numberWithInt:5] forKey:@&#8221;_paddingRight&#8221;]; 3\u3001\u81ea\u5b9a\u4e49\u4e00\u4e2aTextField\uff0c\u5b9e\u73b0\u5982\u4e0b\u4e24\u4e2a\u65b9\u6cd5 \/\/\u63a7\u5236placeHolder \u7684\u4f4d\u7f6e\uff0c\u5de6\u53f3\u7f29 8px &#8211; (CGRect)textRectForBounds:(CGRect)bounds { return CGRectInset(bounds , 8 , 0 ); } \/\/ \u63a7\u5236\u6587\u672c\u7684\u4f4d\u7f6e\uff0c\u5de6\u53f3\u7f29 8px &#8211; (CGRect)editingRectForBounds:(CGRect)bounds { [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[15],"class_list":["post-395","post","type-post","status-publish","format-standard","hentry","category-project","tag-module"],"_links":{"self":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/comments?post=395"}],"version-history":[{"count":0,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/395\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/media?parent=395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/categories?post=395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/tags?post=395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}