iOS Sina Weibo Uitextview package (temporarily excluding emoticons on keyboard)

Source: Internet
Author: User

The first part of the goal effect

The goals to be achieved today are as follows:

The second part of theoretical knowledge

From the above image and our frequent use of Sina Weibo experience, a click on the text input box will be called out of the keyboard will have two controls, one is Uitxtfield and Uitextview, then choose which control is OK, before selecting the control, we first look at their differences

The above table can be found that Uitextview has no placeholder attribute, but Uitextfield has, but, Uitextfield can only display a line of text, and Uitextview can display any line of text, on the actual effect, We choose Uitextview, and rewrite some of its methods, for the purpose of this time, add two properties, placeholder and placeholdercolor can be. After the goal is determined, we create a new class Lhtextview, inherited from Uitextview,

It's header files such as

So how do you show placeholder? , here we take quart2d drawing technique, redraw this placeholder, implement this method in the. m file as

Since the two properties are declared in the header file, the setter method must be called when called, so we also rewrite these two setter methods in. m files,

In order to change the text and font size of TextView in real time, it is also possible to rewrite their setter method

Of course, we customize the control and definitely implement its initialization method:

In this case, the custom control method is finished.

The third part of the test effect

After the custom space of course need to test, read is not correct, in this method to modify placeholder and Placeholdercolor two properties

We modify its font size (font property) to test, and the results are as follows

Change the color to orange as follows

The above test can be found, even if the test pass it, and finally don't forget to remove the notice OH


Well, today's blog on this, speak poorly, welcome criticism or message exchange!






iOS Sina Weibo Uitextview package (temporarily excluding emoticons on keyboard)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.