ios - How to make UITextView from scratch? -
as understand, apple not provide source code uikit. in order answer another question, though, trying understand how uitextview
works (or made work) under hood.
how set minimal uitextview
myself?
i see documentation inherits uiscrollview
assume start there.
import uikit class myuitextview: uiscrollview { // ??? }
again looking @ text view docs, looks need @ minimum implement init
method , text
property. (i can ignore editing aspects , formatting attributes now.)
the init
method takes following form:
init(frame frame: cgrect, textcontainer textcontainer: nstextcontainer?)
so need property nstextcontainer
. textkit
component works nstextstorage
, nslayoutmanager
need work in somewhere, too. set nstextstorage
text
property don't know how nslayoutmanager
interact here.
has (outside of apple) done before? simple enough question answer here or answer long?
update:
this question shows latest attempt: how initialize nstextstorage string in swift
this complicated. i've had reimplement subset of uilabel before, , tricky. think first thing should think level you're interested in working in. @ it's basic, uitextview
responsible manipulating bitmap graphics context , turning string pixels on screen. in pretty big challenge, , if want reimplement functionality scratch you're going busy while.
at higher level, uitextview
things breaking text lines, displaying different fonts; higher still , have things uitextinput protocol, handles letting user enter , manipulate text view's contents.
in terms of implementation details, aren't available. closest can header dump, interesting might not tell much.
until ios7 , textkit, text rendering handled webkit, means implementation potentially more of mess having undergone transition.
anyway, things point in right (or @ least a) direction:
- nsattributedstring class reference, uikit additions, let blit text graphics context;
- introducing textkit, sample code wwdc13 (there's accompanying video well)
- intro text kit appcoda.
i apologize answer isn't useful i'd intended. basically: big question; it's multiple big questions.
Comments
Post a Comment