文本流向顶端,如何使文本中心像这样:
解决方法 只是子类NSTextFIEld( or swizzle it)…并实现…- (NSRect) TitleRectForBounds:(NSRect)frame { CGfloat stringHeight = self.attributedStringValue.size.height; NSRect TitleRect = [super TitleRectForBounds:frame]; TitleRect.origin.y = frame.origin.y + (frame.size.height - stringHeight) / 2.0; return TitleRect; }- (voID) drawInteriorWithFrame:(NSRect)cFrame inVIEw:(NSVIEw*)cVIEw { [super drawInteriorWithFrame:[self TitleRectForBounds:cFrame] inVIEw:cVIEw]; }总结
以上是内存溢出为你收集整理的objective-c – 在NSTextField中设置文本垂直中心全部内容,希望文章能够帮你解决objective-c – 在NSTextField中设置文本垂直中心所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)