[SWIFT] Difference between byCharWrapping and byWordWrapping of UI Label in Japanese display

Introduction

Swift's UILabel provides a property called lineBreakMode to specify wrapping and abbreviation. Among the modes that can be specified, there are byWordWrapping that separates the wrapping position by words and byCharWrapping that separates characters, but even if byWordWrapping is specified, Japanese sentences are not displayed by word separation. Then, I was wondering if there is any difference between specifying byCharWrapping and byWordWrapping, so I checked it.

environment

Xcode Version 12.0 Swift 5.3

byCharWrapping When I specified byCharWrapping for lineBreakMode and displayed it, it looks like the image. The background of UILabel is yellow for clarity. image.png

byWordWrapping Next, I specified byWordWrapping to display the same sentence. If you specify byWordWrapping, it seems to be adjusted so that punctuation marks, the end of parentheses, lowercase letters, stretch bars, etc. do not appear at the beginning of the line. This is easier to read. image.png

Summary

If you can specify either byCharWrapping or byWordWrapping, it seems better to use byWordWrapping, which takes kinsoku rules into consideration.

■ Reference site https://developer.apple.com/documentation/uikit/nslinebreakmode

Recommended Posts

Difference between byCharWrapping and byWordWrapping of UI Label in Japanese display
Difference between final and Immutable in Java
Difference between isEmpty and isBlank of StringUtils
Difference between getText () and getAttribute () in Selenium
Difference between "|| =" and "instance_variable_defined?" In Ruby memoization
Difference between EMPTY_ELEMENTDATA and DEFAULTCAPACITY_EMPTY_ELEMENTDATA in ArrayList
Difference between addPanel and presentModally of FloatingPanel
Difference between int and Integer in Java
[Rails] Difference in behavior between delegate and has_many-through in the case of one-to-one-to-many
Difference between next () and nextLine () in Java Scanner
Use of Japanese fonts and external characters in JasperReport
About the difference between classes and instances in Ruby
Difference between new and create in Rais action controller
[Java] Difference between static final and final in member variables
[Ruby] Difference between get and post
Get the result of POST in Java
Understand in 3 minutes! A very rough explanation of the difference between session and cookie
Difference between vh and%
Automatically set the width and height of the UI Label
Difference between i ++ and ++ i
What is the difference between the responsibilities of the domain layer and the application layer in the onion architecture [DDD]
[Docker-compose] Difference between env_file and environment. Priority of environment variable application
About the difference between "(double quotation)" and "single quotation" in Ruby
Jersey --What is Difference Between bind and bindAsContract in HK2?
Difference between element 0, null and empty string (check in list)
[Ruby] About the difference between 2 dots and 3 dots of range object.
[Java] Difference between assignment of basic type variable and assignment of reference type variable
[Java] Difference between Stack Overflow Error and Out Of Memory Error
Is short-circuit evaluation really fast? Difference between && and & in Java
Difference between product and variant
Difference between redirect_to and render
[Java] Difference between == and equals
Rails: Difference between resources and resources
Difference between puts and print
Difference between redirect_to and render
Difference between CUI and GUI
Difference between variables and instance variables
Difference between mockito-core and mockito-all
Difference between class and instance
Difference between bundle and bundle install
Difference between ArrayList and LinkedList
Difference between render and redirect_to
Difference between List and ArrayList
Difference between .bashrc and .bash_profile
Difference between StringBuilder and StringBuffer
Difference between render and redirect_to
Difference between render and redirect_to
Problems and solutions for UI collapse when inputting Japanese in swing
Output the difference between each field of two objects in Java
Set "Fixed display of rows and columns" and "Validation rules" in rubyXL
The difference between puts and print in Ruby is not just the presence or absence of line breaks
[Ruby] Difference between get and post
Difference between instance method and class method
Difference between render method and redirect_to
Difference between interface and abstract class
Difference between == operator and equals method
[Terminal] Difference between irb and pry
JavaServlet: Difference between executeQuery and executeUpdate
Difference between == operator and eqals method
Rough difference between RSpec and minitest
[Rails] Difference between find and find_by
Understand the difference between each_with_index and each.with_index