Bordered UITextView
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Adding a border to UITextView is simple, but polished results require more than just setting one layer property. Real apps need border states, padding, dark-mode compatibility, and accessibility-safe feedback. A reusable styled component keeps behavior consistent across forms and reduces repetitive controller code.
Base Border Styling
UITextView draws through its layer, so border and corner settings live there.
This gives a clean baseline for most screens.
Improve Input Comfort with Insets
Default text container spacing often feels cramped. Increase insets explicitly:
Setting line fragment padding helps align text with neighboring controls when precise layout is required.
Create a Reusable Subclass
A custom subclass prevents copy-paste style setup.
Register this in design system modules so every screen starts with the same baseline style.
Add Focus and Error States
Borders should communicate field state clearly.
Combine color changes with text hints for accessibility. Color alone is not sufficient feedback.
Dynamic Type and Accessibility
If users increase text size, bordered text view should still remain readable.
Also test VoiceOver navigation and focus transitions. Border changes triggered by editing state should not conflict with accessibility focus indicators.
Dark Mode and Theming
Avoid hardcoded colors such as fixed light-gray RGB values. Use semantic system colors or theme tokens. This ensures borders stay visible in light and dark mode.
If your app has branded themes, map design tokens to border style in one place so updates do not require touching every screen.
Performance Notes
Layer border settings are cheap, but avoid heavy shadows and complex masks on large numbers of scrolling cells. If many text views appear in table or collection views, preconfigure style in reusable views and avoid repeated expensive updates in cellForRowAt.
Placeholder and Empty State UX
UITextView has no built-in placeholder like UITextField. Many apps add a lightweight placeholder label and hide it when text is non-empty. Keep placeholder color subtle and ensure it remains readable in dark mode.
This small enhancement improves usability in feedback and notes screens where users expect field hints.
Common Pitfalls
- Hardcoding border colors that disappear or look wrong in dark mode.
- Forgetting text insets, resulting in cramped text appearance.
- Duplicating style code across multiple view controllers.
- Using border color as the only validation signal.
- Applying expensive visual effects that hurt scroll performance.
Summary
- Use layer properties for border width, color, and corner radius.
- Add text container insets for better readability.
- Prefer a reusable subclass to enforce consistent styling.
- Implement explicit focus and error border states.
- Validate behavior in dark mode and accessibility settings.

