如何创建包装UIOffset结构的NSValue?

JoJ*_*oJo 1 cocoa-touch ios

我正在尝试更改UISegmentedControl的文本阴影位置.要做到这一点,该文件说,我需要在通过NSValue它包装一个UIOffset结构.

UITextAttributeTextShadowOffset
    Key to the offset used for the text shadow in a text attributes dictionary.
    The corresponding value is an instance of NSValue wrapping a UIOffset struct.
    Available in iOS 5.0 and later.
    Declared in UIStringDrawing.h.
Run Code Online (Sandbox Code Playgroud)

问题是NSValue没有这样的UIOffset结构的包装方法 - 只需搜索文档.我看到很多示例代码使用这个不存在的函数.

[NSValue valueWithUIOffset:UIOffsetMake(0, 1)]
Run Code Online (Sandbox Code Playgroud)

当我尝试运行它时崩溃了.我不明白有多少示例代码可以运行它.

Kri*_*ass 5

查看NSValue UIKit Additions,这是一个类别,除了其他有用的东西之外,还添加了-[NSValue valueWithUIOffset:]你所追求的方法.