本文整理汇总了Java中org.robovm.apple.uikit.UILabel.setTextAlignment方法的典型用法代码示例。如果您正苦于以下问题:Java UILabel.setTextAlignment方法的具体用法?Java UILabel.setTextAlignment怎么用?Java UILabel.setTextAlignment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.robovm.apple.uikit.UILabel
的用法示例。
在下文中一共展示了UILabel.setTextAlignment方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MyViewController
import org.robovm.apple.uikit.UILabel; //导入方法依赖的package包/类
public MyViewController() {
// Get the view of this view controller.
UIView view = getView();
// Setup background.
view.setBackgroundColor(UIColor.white());
// Setup label.
label = new UILabel(new CGRect(20, 250, 280, 44));
label.setFont(UIFont.getSystemFont(24));
label.setTextAlignment(NSTextAlignment.Center);
view.addSubview(label);
// Setup button.
button = new UIButton(UIButtonType.RoundedRect);
button.setFrame(new CGRect(110, 150, 100, 40));
button.setTitle("Click me!", UIControlState.Normal);
button.getTitleLabel().setFont(UIFont.getBoldSystemFont(22));
button.addOnTouchUpInsideListener((control, event) -> label.setText("Click Nr. " + (++clickCount)));
view.addSubview(button);
}
示例2: MyViewController
import org.robovm.apple.uikit.UILabel; //导入方法依赖的package包/类
public MyViewController() {
// Get the view of this view controller.
UIView view = getView();
// Get the bounds of the view.
double viewWidth = view.getBounds().getWidth();
double viewHeight = view.getBounds().getHeight();
// Setup a label. Centered in the top half of the screen.
double labelWidth = viewWidth;
double labelHeight = 150;
double labelX = (viewWidth - labelWidth) / 2.0;
double labelY = (viewHeight * 1.0 / 4.0) - labelHeight / 2.0;
label = new UILabel(new CGRect(labelX, labelY, labelWidth, labelHeight));
label.setFont(UIFont.getSystemFont(40));
label.setTextAlignment(NSTextAlignment.Center);
view.addSubview(label);
// Setup a button. Centered in the bottom half of the screen.
double buttonWidth = viewWidth - 200;
double buttonHeight = 150;
double buttonX = (viewWidth - buttonWidth) / 2.0;
double buttonY = (viewHeight * 3.0 / 4.0) - buttonHeight / 2.0;
button = new UIButton(UIButtonType.RoundedRect);
button.setFrame(new CGRect(buttonX, buttonY, buttonWidth, buttonHeight));
button.setTitle("Click me!", UIControlState.Normal);
button.getTitleLabel().setFont(UIFont.getBoldSystemFont(40));
// Listen on clicks on the button and update the label.
button.addOnPrimaryActionTriggeredListener((control) -> label.setText("Click Nr. " + (++clickCount)));
view.addSubview(button);
}
示例3: Cell
import org.robovm.apple.uikit.UILabel; //导入方法依赖的package包/类
public Cell(CGRect frame) {
super(frame);
// change to our custom selected background view
CustomCellBackground backgroundView = new CustomCellBackground(CGRect.Zero());
setSelectedBackgroundView(backgroundView);
image = new UIImageView(new CGRect(5, 6, 144, 105));
addSubview(image);
label = new UILabel(new CGRect(0, 109, 153, 18));
label.setFont(UIFont.getSystemFont(12));
label.setTextColor(UIColor.white());
label.setTextAlignment(NSTextAlignment.Center);
addSubview(label);
}
示例4: generateTextArea
import org.robovm.apple.uikit.UILabel; //导入方法依赖的package包/类
private UIView generateTextArea(String title, String text,
UIView previousView) {
UILabel textViewTitle = new UILabel();
textViewTitle.setTranslatesAutoresizingMaskIntoConstraints(false);
textViewTitle.setLineBreakMode(NSLineBreakMode.TruncatingTail);
textViewTitle.setNumberOfLines(0);
textViewTitle.setText(title);
textViewTitle.setTextAlignment(NSTextAlignment.Center);
textViewTitle.setFont(UIFont.getBoldSystemFont(UIFont
.getButtonFontSize()));
UILabel textViewText = new UILabel();
textViewText.setTranslatesAutoresizingMaskIntoConstraints(false);
textViewText.setLineBreakMode(NSLineBreakMode.WordWrapping);
textViewText.setNumberOfLines(0);
textViewText.setText(text);
textViewText.setFont(UIFont.getSystemFont(UIFont
.getSmallSystemFontSize()));
mainView.addSubview(textViewTitle);
mainView.addSubview(textViewText);
// mainView.addSubview(toReturn);
// uiview
// if (previousView == null) {
// mainView.addConstraint(NSLayoutConstraint.create(toReturn,
// NSLayoutAttribute.Top, NSLayoutRelation.Equal, mainView,
// NSLayoutAttribute.Top, 1, 10));
// } else {
// mainView.addConstraint(NSLayoutConstraint.create(toReturn,
// NSLayoutAttribute.Top, NSLayoutRelation.Equal,
// previousView, NSLayoutAttribute.Bottom, 1, 10));
// }
// mainView.addConstraint(NSLayoutConstraint.create(toReturn,
// NSLayoutAttribute.Width, NSLayoutRelation.Equal, mainView,
// NSLayoutAttribute.Width, 1, 0));
// mainView.addConstraint(NSLayoutConstraint.create(toReturn,
// NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, mainView,
// NSLayoutAttribute.CenterX, 1, 0));
// title
mainView.addConstraint(NSLayoutConstraint.create(textViewTitle,
NSLayoutAttribute.Width, NSLayoutRelation.Equal, mainView,
NSLayoutAttribute.Width, 1, -40));
mainView.addConstraint(NSLayoutConstraint.create(textViewTitle,
NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, mainView,
NSLayoutAttribute.CenterX, 1, 0));
if (previousView == null) {
mainView.addConstraint(NSLayoutConstraint.create(textViewTitle,
NSLayoutAttribute.Top, NSLayoutRelation.Equal, mainView,
NSLayoutAttribute.Top, 1, 10));
} else {
mainView.addConstraint(NSLayoutConstraint.create(textViewTitle,
NSLayoutAttribute.Top, NSLayoutRelation.Equal,
previousView, NSLayoutAttribute.Bottom, 1, 10));
}
// text
mainView.addConstraint(NSLayoutConstraint.create(textViewText,
NSLayoutAttribute.Width, NSLayoutRelation.Equal, mainView,
NSLayoutAttribute.Width, 1, -40));
mainView.addConstraint(NSLayoutConstraint.create(textViewText,
NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, mainView,
NSLayoutAttribute.CenterX, 1, 0));
mainView.addConstraint(NSLayoutConstraint.create(textViewText,
NSLayoutAttribute.Top, NSLayoutRelation.Equal, textViewTitle,
NSLayoutAttribute.Bottom, 1, 10));
return textViewText;
}
示例5: ParentViewController
import org.robovm.apple.uikit.UILabel; //导入方法依赖的package包/类
public ParentViewController() {
NSNotificationCenter.getDefaultCenter().addObserver(StoreObserver.IAPPurchaseNotification,
StoreObserver.getInstance(),
NSOperationQueue.getMainQueue(), new VoidBlock1<NSNotification>() {
@Override
public void invoke(NSNotification a) {
handlePurchasesNotification(a);
}
});
segmentedControl = new UISegmentedControl(NSArray.fromStrings("Products", "Purchases"));
segmentedControl.setSelectedSegment(0);
segmentedControl.addOnValueChangedListener(new UIControl.OnValueChangedListener() {
@Override
public void onValueChanged(UIControl control) {
segmentValueChanged(control);
}
});
getNavigationItem().setTitleView(segmentedControl);
getNavigationItem().setRightBarButtonItem(
new UIBarButtonItem("Restore", UIBarButtonItemStyle.Done, new UIBarButtonItem.OnClickListener() {
@Override
public void onClick(UIBarButtonItem barButtonItem) {
restore();
}
}));
UIView view = getView();
view.setBackgroundColor(UIColor.white());
statusMessage = new UILabel(new CGRect(0, 64, 320, 44));
statusMessage.setTextAlignment(NSTextAlignment.Center);
statusMessage.setFont(UIFont.getSystemFont(14));
containerView = new UIView(UIScreen.getMainScreen().getApplicationFrame());
view.addSubview(containerView);
productsList = new IOSProductsList();
purchasesList = new IOSPurchasesList();
// Add iOSProductsList and iOSPurchasesList as child view controllers
addChildViewController(productsList);
productsList.didMoveToParentViewController(this);
addChildViewController(purchasesList);
purchasesList.didMoveToParentViewController(this);
// iOSProductsList is the default child view controller
cycleViewControllers(null, productsList);
}
示例6: MyViewController
import org.robovm.apple.uikit.UILabel; //导入方法依赖的package包/类
public MyViewController() {
UIView view = getView();
// Setup background.
UIImageView background = new UIImageView(UIImage.getImage("Background.png"));
background.setFrame(UIScreen.getMainScreen().getBounds());
view.addSubview(background);
// Setup textfield.
textField = new UITextField(new CGRect(44, 32, 232, 31));
textField.setBorderStyle(UITextBorderStyle.RoundedRect);
textField.setPlaceholder("Hello, World!");
textField.setClearsOnBeginEditing(true);
textField.setKeyboardType(UIKeyboardType.ASCIICapable);
textField.setReturnKeyType(UIReturnKeyType.Done);
// When the user starts typing, show the clear button in the text field.
textField.setClearButtonMode(UITextFieldViewMode.WhileEditing);
textField.setDelegate(new UITextFieldDelegateAdapter() {
@Override
public boolean shouldReturn(UITextField theTextField) {
// When the user presses return, take focus away from the text
// field so that the keyboard is dismissed.
if (theTextField == textField) {
textField.resignFirstResponder();
// Invoke the method that changes the greeting.
updateString();
}
return true;
}
});
view.addSubview(textField);
// Setup label.
label = new UILabel(new CGRect(20, 104, 280, 44));
label.setFont(UIFont.getSystemFont(24));
label.setTextColor(UIColor.white());
label.setTextAlignment(NSTextAlignment.Center);
// When the view first loads, display the placeholder text that's in the
// text field in the label.
label.setText(textField.getPlaceholder());
view.addSubview(label);
}