This demonstrates using the CMIndexBar class from https://github.com/CraigMerchant/CMIndexBar. This shows you how to implement the index bar as well as make it as wide as needed to fit longer text.