如何让我的 iOS TTTextEditor 圆角在 Three20 中减少锯齿?
我正在尝试在我的应用程序中重现 iphone/iOS SMS 应用程序的 UI。我正在调整 Three20 TTTextBarController。不幸的是,由于圆角附近出现锯齿,我的努力导致条形变得更加难看。
(StackOverflow 缩小了上面的图像 - 请在全屏模式下查看上面的图像。在该分辨率下,您将看到别名)。
我用来创建文本栏元素的 Three20 样式代码如下:
- (TTStyle*)textBarTextField {
return
[TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:13] next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(6, 0, 3, 6) next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(1, 0, 1, 0) next:
[TTShadowStyle styleWithColor:RGBACOLOR(255,255,255,0.4) blur:0 offset:CGSizeMake(0, 1) next:
[TTSolidFillStyle styleWithColor:RGBACOLOR(255,255,255,1.0) next:
[TTInnerShadowStyle styleWithColor:RGBACOLOR(0,0,0,0.4) blur:3 offset:CGSizeMake(0, 2) next:
[TTBevelBorderStyle styleWithHighlight:RGBACOLOR(0,0,0,0.25) shadow:RGBACOLOR(0,0,0,0.2)
width:1 lightSource:270 next:nil]]]]]]];
}
谁能建议如何提高圆角的质量?或者,有人知道如何逐像素模拟 iOS 短信聊天栏吗?
谢谢!
更新
我的原始代码来自TTDefaultStyles.m。
简化后,我得出了这种样式:
return
[TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:13] next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(6, 0, 4, 6) next:
[TTLinearGradientBorderStyle styleWithColor1:RGBCOLOR(51,51,51)
color2:RGBCOLOR(102, 102, 102) width:1 next:
[TTSolidFillStyle styleWithColor:RGBACOLOR(255,255,255,1.0) next:
[TTInnerShadowStyle styleWithColor:RGBACOLOR(0,0,0,0.8) blur:3 offset:CGSizeMake(0, 2) next:nil
]]]]];
据我所知,TTInnerShadowStyle 是导致锯齿在左上角和右上角可见的原因。我很想获得 Apple 用于其无缝 UITextField 阴影的代码......
I am trying to reproduce the UI for the iphone/iOS SMS app in my application. I am adapting the Three20 TTTextBarController. Unfortunately, my efforts have resulted in a bar that is substantially uglier because of aliasing near the rounded corners.
(StackOverflow shrinks the above image - please view the above image in full-screen mode. At that resolution you will see the aliasing).
The Three20 style code I have used to create the text bar element is as follows:
- (TTStyle*)textBarTextField {
return
[TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:13] next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(6, 0, 3, 6) next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(1, 0, 1, 0) next:
[TTShadowStyle styleWithColor:RGBACOLOR(255,255,255,0.4) blur:0 offset:CGSizeMake(0, 1) next:
[TTSolidFillStyle styleWithColor:RGBACOLOR(255,255,255,1.0) next:
[TTInnerShadowStyle styleWithColor:RGBACOLOR(0,0,0,0.4) blur:3 offset:CGSizeMake(0, 2) next:
[TTBevelBorderStyle styleWithHighlight:RGBACOLOR(0,0,0,0.25) shadow:RGBACOLOR(0,0,0,0.2)
width:1 lightSource:270 next:nil]]]]]]];
}
Can anyone advise how to improve the quality of the rounded corners? Alternatively, has anyone figured out how to pixel-for-pixel emulate the iOS SMS chat bar?
Thanks!
Update
My original code came from TTDefaultStyles.m.
After simplifying I came to this style:
return
[TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:13] next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(6, 0, 4, 6) next:
[TTLinearGradientBorderStyle styleWithColor1:RGBCOLOR(51,51,51)
color2:RGBCOLOR(102, 102, 102) width:1 next:
[TTSolidFillStyle styleWithColor:RGBACOLOR(255,255,255,1.0) next:
[TTInnerShadowStyle styleWithColor:RGBACOLOR(0,0,0,0.8) blur:3 offset:CGSizeMake(0, 2) next:nil
]]]]];
From what I can tell, the TTInnerShadowStyle is what is causing the aliasing to be visible on the top left and right. I'd love to get the code that Apple is using for their seamless UITextField shadow...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在 MessageUI.framework 中使用 MFMessageComposeViewController
Use MFMessageComposeViewController in MessageUI.framework
请在此处查看 HPGrowingTextView 和 GrowingTextView 示例代码: http://www.hanspinckaers .com/multi-line-uitextview-similar-to-sms
它不仅看起来像 iOS 消息应用程序,而且还扩展到多行。
Check out the HPGrowingTextView and GrowingTextView sample code here: http://www.hanspinckaers.com/multi-line-uitextview-similar-to-sms
Not only does it look like the iOS messages app, but it also grows to multilines.
我会剥离你的风格......你有两个连续的插图,一个投影和斜角边框,而且所有的顺序也是随机的。其中任何一个都可能导致您的模糊。为什么不从一个简单的
TTShapeStyle
开始,然后是TTInnerShadowStyle
。I would strip down your style… you have 2 insets in a row, a drop shadow and bevel border, and all in a random order too. Any of these could be causing your blurriness. Why don't you start with just a simple
TTShapeStyle
, then theTTInnerShadowStyle
.尝试将视图设置为不绘制不透明。该视图是用透明胶片绘制的。
Try setting your view to not draw opaque. The view is drawing with transparencies.