私のプロジェクトの多くで、テキストのないアイコンだけのカスタムの戻るボタンを使用しています。私は最善の方法を見つけるためにいくつかの実験を行い、以下の方法を思いつきました(これが最善の方法または唯一の方法であると言っているわけではありませんが、それは私にとってはうまくいき、安定しています)。
私の考えは、標準の戻るボタンのスタイルを変更するルート ViewController を実装することでした。これは簡単なことではありませんでした。さまざまなオプションをいじって約1日後、ようやく実用的なソリューションにたどり着きました。
秘訣は、十分に大きな透明な背景を用意し (実際のバック シェブロンよりも大きい場合は小さいサイズにサイズ変更されます)、シェブロンにカスタム イメージを使用することです。
これは機能しますが、以下の測定値でわかるように、小さな欠点があります。左側に余分な 14 ポイントのギャップがあります。右側に一致するボタンが必要な場合は、これを 14 ポイント補正する必要があります (はい、そのポイントなので、網膜では 28 ピクセルです...)

これは私のコードです:
//this vc implements a custom back button, you can make this a root controller
//from which you inherit all your view controllers. But for simplicity reasons for this explanation
//I skipped this
class VCRoot: UIViewController {
override func viewDidLoad() {
//call supers
super.viewDidLoad()
//create custom back item
let backItem = UIBarButtonItem()
//as image set the back chevron icon its a 22x22 points (so 44x44 in retina)
backItem.image=PaintCode.imageOfBarBtnBack
let b = PaintCode.imageOfBarBtnBackgroundEmpty
//as background I use a 1 = 33 points (so 2x66 retina) fully transparant image
backItem.setBackButtonBackgroundImage(b, forState: UIControlState.Normal, barMetrics: UIBarMetrics.Default)
//set the newly created barbuttonitme as the back button
navigationItem.backBarButtonItem=backItem
}
}
//this vc puts a "forwards" button in the navbar on the right with a matching arrow
//The image of this matching forward arrow is the correct size (width!) so that its the same
//distance from the edge of the screen as the back button
class VC2: UIViewController {
//outlet to the barbutton item from IB
@IBOutlet weak var barbtn: UIBarButtonItem!
override func viewDidLoad() {
//call supers
super.viewDidLoad()
//the forward chevron in the image is shifted 14 points (so 28 retina) to the left
//so it has same distance from edge => its (22+14) x 22 = 36 x 22 points (72 x 44 retina)
barbtn.image=PaintCode.imageOfBarBtnForward
}
}
ここで私のブログを参照することもできます:
http://www.hixfield.net/blog/2015/05/adding-a-custom-back-button-the-standard-way/