Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ストーリーボードに 3 つの UILabels を重ねて配置しています。
静的 UI ラベル 1
動的 UI ラベル 2
静的 UI ラベル 3
ラベル 1 と 3 は静的で、変更されることはありません。ラベル 2 は動的で、常に 1 文の長さですが、折り返して短い文または長い文になる場合があります。テキストの量に基づいて、ラベル 2 をラベル 1 とラベル 3 の間で垂直方向に完全に中央揃えにしたいと考えています。これを行う方法はありますか?大歓迎です!
Label1 と Label3 の中心値を加算し、2 で割って label2 の中心にします。
CGPoint point = CGPointMake(Label2.Center.x,(Label1.center.y+Label3.center.y)/2); Label2.center = point;
それで全部です....