Find coordinates of a substring in UILabel

后端 未结 1 1404
失恋的感觉
失恋的感觉 2021-01-06 15:49

I have a string coming from server which I am displaying on UILabel. It is within that string, I am identifying some particular substring. I want to place a button on that s

相关标签:
1条回答
  • 2021-01-06 16:35

    Might be you can calculate using-

    CGSize stringSize = [string sizeWithFont:myFont 
                           constrainedToSize:maximumSize 
                               lineBreakMode:self.myLabel.lineBreakMode];
    

    Now New position-

    x = self.myLabel.frame.origin.x + stringSize.width
    

    and for y similarly you need to have code with consideration of x.

    0 讨论(0)
提交回复
热议问题