またまたお騒がせします!
文字を縦書きにしてラベルやボタンで書き出し、それをスタンプのように動かす…
といったことをアプリに実装していました。
縦書きに関して、Qiitaのルビを振るという記事を引用させてもらい、作成していました。
let attributed = text .replace(pattern: "(|.+?《.+?》)", template: ",$1,") .components(separatedBy: ",") .map { x -> NSAttributedString in if let pair = x.find(pattern: "|(.+?)《(.+?)》") { let string = (x as NSString).substring(with: pair.rangeAt(1)) let ruby = (x as NSString).substring(with: pair.rangeAt(2)) var text = [.passRetained(ruby) as Unmanaged<CFString>?, .none, .none, .none] let annotation = CTRubyAnnotationCreate(.auto, .auto, 0.5, &text) return NSAttributedString( string: string, attributes: [kCTRubyAnnotationAttributeName as String: annotation]) } else { return NSAttributedString(string: x, attributes: nil) } } .reduce(NSMutableAttributedString()) { $0.append($1); return $0 }
passRetainedがおかしいとXcodeに言われているので、書き順が変わったのかな、と
なんとか四苦八苦コードを書き換えてみたりしたのですが、うまくいかず…><
すみませんが、アドバイスなど
ご協力よろしくお願いします!
---------追記---------
エラー内容追加の指摘、ありがとうございます!すみません!
ver text = [~]のところに
Member 'passRetained' in 'Unmanaged<CFString>?' produces result of type 'Unmanaged<Instance>', but context expects 'Unmanaged<CFString>?'
と表示されます。