OGeek|极客世界-中国程序员成长平台

标题: ios - 退格第一行后如何在 UITextView 中居中对齐文本? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 10:14
标题: ios - 退格第一行后如何在 UITextView 中居中对齐文本?

我希望文本始终居中,但是当我退格第一行的所有文本时,文本不再居中。 有什么解决方案吗?请帮忙...

我已经上传到 youtube ,请看一下

这是我在 UITextView 上的设置

附言其实我试过用 textView.attributedText 做,但没有运气



Best Answer-推荐答案


可以添加 UITextViewDelegate 并实现方法:

-(void)textViewDidChangeUITextView *)textView
{
    textView.textAlignment = NSTextAlignmentCenter;
}

关于ios - 退格第一行后如何在 UITextView 中居中对齐文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23991466/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4