本文整理汇总了Java中org.robovm.apple.uikit.UILabel类的典型用法代码示例。如果您正苦于以下问题:Java UILabel类的具体用法?Java UILabel怎么用?Java UILabel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UILabel类属于org.robovm.apple.uikit包,在下文中一共展示了UILabel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
});
}
开发者ID:liraz,项目名称:robolayout,代码行数:17,代码来源:LayoutAnimationsViewController.java
示例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);
}
开发者ID:robovm,项目名称:robovm-templates,代码行数:23,代码来源:MyViewController.java
示例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;
}
开发者ID:Kourtessia,项目名称:RoboVM-for-iOS,代码行数:22,代码来源:AddressbookUtils.java
示例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));
}
}
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:19,代码来源:InfiniteScrollView.java
示例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();
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:29,代码来源:QuestionViewController.java
示例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()));
}
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:21,代码来源:AAPLStepperViewController.java
示例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));
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:23,代码来源:FeaturedViewController.java
示例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));
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:23,代码来源:FavoritesViewController.java
示例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));
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:23,代码来源:FourViewController.java
示例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);
}
开发者ID:liraz,项目名称:robolayout,代码行数:8,代码来源:LayoutAnimationsViewController.java
示例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");
}
开发者ID:liraz,项目名称:robolayout,代码行数:8,代码来源:ExampleCollectionViewCell.java
示例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);
}
开发者ID:robovm,项目名称:robovm-templates,代码行数:33,代码来源:MyViewController.java
示例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);
}
开发者ID:Kourtessia,项目名称:RoboVM-for-iOS,代码行数:12,代码来源:GenderListTableViewController.java
示例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;
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:9,代码来源:InfiniteScrollView.java
示例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();
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:12,代码来源:InfiniteScrollView.java
示例16: placeNewLabelOnLeft
import org.robovm.apple.uikit.UILabel; //导入依赖的package包/类
private double placeNewLabelOnLeft (double leftEdge) {
UILabel label = insertLabel();
visibleLabels.add(0, label); // add leftmost label at the beginning of the array
CGRect frame = label.getFrame();
frame.getOrigin().setX(leftEdge - frame.getSize().getWidth());
frame.getOrigin().setY(labelContainerView.getBounds().getSize().getHeight() - frame.getSize().getHeight());
label.setFrame(frame);
return frame.getMinX();
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:12,代码来源:InfiniteScrollView.java
示例17: tileLabels
import org.robovm.apple.uikit.UILabel; //导入依赖的package包/类
private void tileLabels (double minimumVisibleX, double maximumVisibleX) {
// the upcoming tiling logic depends on there already being at least one label in the visibleLabels array, so
// to kick off the tiling we need to make sure there's at least one label
if (visibleLabels.size() == 0) {
placeNewLabelOnRight(minimumVisibleX);
}
// add labels that are missing on right side
UILabel lastLabel = visibleLabels.get(visibleLabels.size() - 1);
double rightEdge = lastLabel.getFrame().getMaxX();
while (rightEdge < maximumVisibleX) {
rightEdge = placeNewLabelOnRight(rightEdge);
}
// add labels that are missing on left side
UILabel firstLabel = visibleLabels.get(0);
double leftEdge = firstLabel.getFrame().getMinX();
while (leftEdge > minimumVisibleX) {
leftEdge = placeNewLabelOnLeft(leftEdge);
}
// remove labels that have fallen off right edge
lastLabel = visibleLabels.get(visibleLabels.size() - 1);
while (lastLabel.getFrame().getOrigin().getX() > maximumVisibleX) {
lastLabel.removeFromSuperview();
visibleLabels.remove(visibleLabels.size() - 1);
lastLabel = visibleLabels.get(visibleLabels.size() - 1);
}
// remove labels that have fallen off left edge
firstLabel = visibleLabels.get(0);
while (firstLabel.getFrame().getMaxX() < minimumVisibleX) {
firstLabel.removeFromSuperview();
visibleLabels.remove(0);
firstLabel = visibleLabels.get(0);
}
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:38,代码来源:InfiniteScrollView.java
示例18: LoadingStatus
import org.robovm.apple.uikit.UILabel; //导入依赖的package包/类
public LoadingStatus(CGRect frame) {
super(frame);
setBackgroundColor(UIColor.fromRGBA(0, 0, 0, 0.4));
String loadingString = "Loading Photos…";
UIFont loadingFont = UIFont.getBoldSystemFont(17);
NSAttributedStringAttributes attrs = new NSAttributedStringAttributes().setFont(loadingFont);
CGRect rect = new NSString(loadingString).getBoundingRect(new CGSize(frame.getWidth(), frame.getHeight()),
NSStringDrawingOptions.with(NSStringDrawingOptions.UsesLineFragmentOrigin,
NSStringDrawingOptions.UsesFontLeading), attrs, null);
CGSize labelSize = rect.getSize();
double centerX = Math.floor((frame.getWidth() / 2) - (labelSize.getWidth() / 2));
double centerY = Math.floor((frame.getHeight() / 2) - (labelSize.getHeight() / 2));
loadingLabel = new UILabel(new CGRect(centerX, centerY, labelSize.getWidth(), labelSize.getHeight()));
loadingLabel.setBackgroundColor(UIColor.clear());
loadingLabel.setTextColor(UIColor.white());
loadingLabel.setText(loadingString);
loadingLabel.setFont(loadingFont);
progress = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.White);
CGRect progressFrame = progress.getFrame();
progressFrame.getOrigin().setX(centerX - progressFrame.getWidth() - 8);
progressFrame.getOrigin().setY(centerY);
progress.setFrame(progressFrame);
addSubview(progress);
addSubview(loadingLabel);
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:32,代码来源:LoadingStatus.java
示例19: setElement
import org.robovm.apple.uikit.UILabel; //导入依赖的package包/类
public void setElement(AtomicElement element) {
this.element = element;
AtomicElementTileView elementTileView = (AtomicElementTileView) getContentView().getViewWithTag(1);
elementTileView.setElement(element);
UILabel labelView = (UILabel) getContentView().getViewWithTag(2);
labelView.setText(element.getName());
elementTileView.setNeedsDisplay();
labelView.setNeedsDisplay();
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:13,代码来源:AtomicElementTableViewCell.java
示例20: 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
注:本文中的org.robovm.apple.uikit.UILabel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论