当前位置: 首页>>代码示例>>Java>>正文


Java UILabel.setTextAlignment方法代码示例

本文整理汇总了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);
}
 
开发者ID:robovm,项目名称:robovm-templates,代码行数:23,代码来源:MyViewController.java

示例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);
}
 
开发者ID:robovm,项目名称:robovm-templates,代码行数:33,代码来源:MyViewController.java

示例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);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:16,代码来源:Cell.java

示例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;
   }
 
开发者ID:wolfgang-s,项目名称:owncloud-gallery,代码行数:68,代码来源:HelpViewController.java

示例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);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:51,代码来源:ParentViewController.java

示例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);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:43,代码来源:MyViewController.java


注:本文中的org.robovm.apple.uikit.UILabel.setTextAlignment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。