本文整理汇总了Java中org.robovm.apple.uikit.UILabel类的典型用法代码示例。如果您正苦于以下问题:Java UILabel类的具体用法?Java UILabel怎么用?Java UILabel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UILabel类属于org.robovm.apple.uikit包,在下文中一共展示了UILabel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: didPressButton
import org.robovm.apple.uikit.UILabel; //导入依赖的package包/类
@Method(selector = "didPressButton")
public void didPressButton() {
UILabel textLabel = (UILabel) UIViewLayoutUtil.findViewById(getView(), "text");
if(textLabel.getText().equals("Short text")) {
textLabel.setText("Very long long text");
} else {
textLabel.setText("Short text");
}
UIView.animate(0.2, new Runnable() {
@Override
public void run() {
getView().layoutIfNeeded();
}
});
}
示例2: 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);
}
示例3: setContentOfCell
import org.robovm.apple.uikit.UILabel; //导入依赖的package包/类
public static UITableViewCell setContentOfCell(String name, NSURL url, String adresse, String email) {
UITableViewCell cell = new UITableViewCell(new CGRect(0, 0, 300, 60));
UIImageView img = new UIImageView(new CGRect(20, 10, 70, 70));
NSData data = (NSData)NSData.read(url);
img.setImage(new UIImage(data));
cell.getContentView().addSubview(img);
UILabel label1 = new UILabel(new CGRect(100, 10, cell.getContentView().getFrame().getWidth(), 20));
label1.setText(name);
label1.setTextColor(UIColor.colorBrown());
cell.getContentView().addSubview(label1);
UILabel label2 = new UILabel(new CGRect(100, 35, cell.getContentView().getFrame().getWidth(), 20));
label2.setText(adresse);
cell.getContentView().addSubview(label2);
UILabel label3 = new UILabel(new CGRect(100, 55, cell.getContentView().getFrame().getWidth(), 20));
label3.setText(email);
cell.getContentView().addSubview(label3);
return cell;
}
示例4: recenterIfNecessary
import org.robovm.apple.uikit.UILabel; //导入依赖的package包/类
/** Recenter content periodically to achieve impression of infinite scrolling. */
private void recenterIfNecessary () {
CGPoint currentOffset = getContentOffset();
double contentWidth = getContentSize().getWidth();
double centerOffsetX = (contentWidth - getBounds().getSize().getWidth()) / 2.0;
double distanceFromCenter = Math.abs(currentOffset.getX() - centerOffsetX);
if (distanceFromCenter > (contentWidth / 4.0)) {
setContentOffset(currentOffset.setX(centerOffsetX));
// move content by the same amount so it appears to stay still
for (UILabel label : visibleLabels) {
CGPoint center = labelContainerView.convertPointToView(label.getCenter(), this);
center.setX(center.getX() + centerOffsetX - currentOffset.getX());
label.setCenter(convertPointToView(center, labelContainerView));
}
}
}
示例5: getHeightForRow
import org.robovm.apple.uikit.UILabel; //导入依赖的package包/类
/**
* This delegate method is implemented because the height of the cell
* displaying the question will need to change depending on the height
* required to display the question text. As the device rotates this will
* change.
*/
@Override
public double getHeightForRow(UITableView tableView, NSIndexPath indexPath) {
if (indexPath.getSection() == 0) {
UITableViewCell questionCell = tableView.dequeueReusableCell("QuestionCell");
UILabel questionLabel = questionCell.getTextLabel();
// The width must be constrained to the width of the table view
// minus the
// left and right margin of a grouped style cell.
// Unfortunately, there is no way to lookup exactly what that margin
// is, so
// it must be hardcoded.
// The height is left unconstrained.
CGSize constrainingSize = new CGSize(tableView.getBounds().getSize().getWidth() - 40 * 2, Float.MAX_VALUE);
NSAttributedString string = new NSAttributedString(questionLabel.getText(),
new NSAttributedStringAttributes().setFont(questionLabel.getFont()));
return string.getBoundingRect(constrainingSize, NSStringDrawingOptions.UsesLineFragmentOrigin, null)
.getHeight() + 22;
}
return tableView.getRowHeight();
}
示例6: onValueChanged
import org.robovm.apple.uikit.UILabel; //导入依赖的package包/类
@Override
public void onValueChanged(UIControl control) {
UIStepper stepper = (UIStepper) control;
System.out.println(String.format("A stepper changed its value: %s.", control));
// Figure out which stepper was selected and update its associated
// label.
UILabel stepperLabel = null;
if (defaultStepper == stepper) {
stepperLabel = defaultStepperLabel;
} else if (tintedStepper == stepper) {
stepperLabel = tintedStepperLabel;
} else if (customStepper == stepper) {
stepperLabel = customStepperLabel;
}
if (stepperLabel != null) {
stepperLabel.setText(String.valueOf((int) stepper.getValue()));
}
}
示例7: FeaturedViewController
import org.robovm.apple.uikit.UILabel; //导入依赖的package包/类
public FeaturedViewController() {
setTabBarItem(new UITabBarItem(UITabBarSystemItem.Featured, 0));
UIView view = getView();
view.setBackgroundColor(UIColor.fromRGBA(0.9, 1, 0.7, 1));
titleLabel = new UILabel(new CGRect(0, 0, 100, 100));
titleLabel.setFont(UIFont.getSystemFont(17));
titleLabel.setText("Featured");
titleLabel.setTranslatesAutoresizingMaskIntoConstraints(false);
view.addSubview(titleLabel);
// Layout
Map<String, NSObjectProtocol> views = new HashMap<>();
views.put("parent", view);
views.put("title", titleLabel);
view.addConstraints(NSLayoutConstraint.createConstraints("H:[parent]-(<=1)-[title]",
NSLayoutFormatOptions.AlignAllCenterY, null, views));
view.addConstraints(NSLayoutConstraint.createConstraints("V:[parent]-(<=1)-[title]",
NSLayoutFormatOptions.AlignAllCenterX, null, views));
}
示例8: FavoritesViewController
import org.robovm.apple.uikit.UILabel; //导入依赖的package包/类
public FavoritesViewController() {
setTabBarItem(new UITabBarItem(UITabBarSystemItem.Favorites, 0));
UIView view = getView();
view.setBackgroundColor(UIColor.fromRGBA(0.77, 1, 1, 1));
titleLabel = new UILabel(new CGRect(0, 0, 100, 100));
titleLabel.setFont(UIFont.getSystemFont(17));
titleLabel.setText("Favorites");
titleLabel.setTranslatesAutoresizingMaskIntoConstraints(false);
view.addSubview(titleLabel);
// Layout
Map<String, NSObjectProtocol> views = new HashMap<>();
views.put("parent", view);
views.put("title", titleLabel);
view.addConstraints(NSLayoutConstraint.createConstraints("H:[parent]-(<=1)-[title]",
NSLayoutFormatOptions.AlignAllCenterY, null, views));
view.addConstraints(NSLayoutConstraint.createConstraints("V:[parent]-(<=1)-[title]",
NSLayoutFormatOptions.AlignAllCenterX, null, views));
}
示例9: FourViewController
import org.robovm.apple.uikit.UILabel; //导入依赖的package包/类
public FourViewController() {
setTabBarItem(new UITabBarItem("Four", UIImage.getImage("tab4"), 0));
UIView view = getView();
view.setBackgroundColor(UIColor.fromRGBA(0.32, 1, 0.3, 1));
titleLabel = new UILabel();
titleLabel.setFont(UIFont.getSystemFont(17));
titleLabel.setText("FOUR");
titleLabel.setTranslatesAutoresizingMaskIntoConstraints(false);
view.addSubview(titleLabel);
// Layout
Map<String, NSObjectProtocol> views = new HashMap<>();
views.put("parent", view);
views.put("title", titleLabel);
view.addConstraints(NSLayoutConstraint.createConstraints("H:[parent]-(<=1)-[title]",
NSLayoutFormatOptions.AlignAllCenterY, null, views));
view.addConstraints(NSLayoutConstraint.createConstraints("V:[parent]-(<=1)-[title]",
NSLayoutFormatOptions.AlignAllCenterX, null, views));
}
示例10: viewDidLoad
import org.robovm.apple.uikit.UILabel; //导入依赖的package包/类
@Override
public void viewDidLoad() {
super.viewDidLoad();
UILabel otherLabel = (UILabel) UIViewLayoutUtil.findViewById(getView(), "otherText");
otherLabel.setContentMode(UIViewContentMode.ScaleToFill);
}
示例11: ExampleCollectionViewCell
import org.robovm.apple.uikit.UILabel; //导入依赖的package包/类
public ExampleCollectionViewCell(CGRect frame) {
super("collectionViewCell.xml");
titleLabel = (UILabel) findViewById("title");
subtitleLabel = (UILabel) findViewById("subtitle");
descriptionLabel = (UILabel) findViewById("description");
}
示例12: 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);
}
示例13: setContentOfCell
import org.robovm.apple.uikit.UILabel; //导入依赖的package包/类
public void setContentOfCell(UITableViewCell cell, String txt, NSURL url) {
UIImageView img = new UIImageView(new CGRect(25, 5, 80, 80));
NSData data = (NSData) NSData.read(url);
img.setImage(new UIImage(data));
cell.getContentView().addSubview(img);
UILabel label = new UILabel(new CGRect(120, 30, cell.getContentView()
.getFrame().getWidth(), 20));
label.setText(txt);
cell.getContentView().addSubview(label);
}
示例14: insertLabel
import org.robovm.apple.uikit.UILabel; //导入依赖的package包/类
private UILabel insertLabel () {
UILabel label = new UILabel(new CGRect(0, 0, 500, 80));
label.setNumberOfLines(3);
label.setText("1024 Block Street\nShaffer, CA\n95014");
labelContainerView.addSubview(label);
return label;
}
示例15: placeNewLabelOnRight
import org.robovm.apple.uikit.UILabel; //导入依赖的package包/类
private double placeNewLabelOnRight (double rightEdge) {
UILabel label = insertLabel();
visibleLabels.add(label); // add rightmost label at the end of the array
CGRect frame = label.getFrame();
frame.getOrigin().setX(rightEdge);
frame.getOrigin().setY(labelContainerView.getBounds().getSize().getHeight() - frame.getSize().getHeight());
label.setFrame(frame);
return frame.getMaxX();
}