iOS でコントロール センターを表示する際に問題が発生しました。この問題に関するドキュメントを検索しましたが、答えが見つかりませんでした。UIButton をクリックしてコントロール センターを表示する方法はありますか?
1 に答える
0
特定の UI 要素にプログラムで制約を適用できます ( iOS 開発者ドキュメントへのリンク) 。
この例のサンプルコード:
// Center horizontally
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:viewToBeCentered
attribute:NSLayoutAttributeCenterX
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeCenterX
multiplier:1.0
constant:0.0]];
// Center vertically
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:viewToBeCentered
attribute:NSLayoutAttributeCenterY
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeCenterY
multiplier:1.0
constant:0.0]];
このコードをボタンのアクション コードに含めることができます。
これが望ましい効果を達成するのに役立つことを願っています!
于 2014-12-11T07:44:19.300 に答える