本文整理汇总了Java中org.robovm.apple.uikit.UILabel.setFont方法的典型用法代码示例。如果您正苦于以下问题:Java UILabel.setFont方法的具体用法?Java UILabel.setFont怎么用?Java UILabel.setFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.robovm.apple.uikit.UILabel
的用法示例。
在下文中一共展示了UILabel.setFont方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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));
}
示例3: 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));
}
示例4: 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));
}
示例5: 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);
}
示例6: 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);
}
示例7: 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);
}
示例8: ModalViewController
import org.robovm.apple.uikit.UILabel; //导入方法依赖的package包/类
public ModalViewController() {
UIView view = getView();
view.setBackgroundColor(UIColor.white());
titleLabel = new UILabel();
titleLabel.setFont(UIFont.getSystemFont(17));
titleLabel.setTranslatesAutoresizingMaskIntoConstraints(false);
view.addSubview(titleLabel);
UIButton button = new UIButton(UIButtonType.RoundedRect);
button.setTitle("Done", UIControlState.Normal);
button.setTitleShadowColor(UIColor.fromWhiteAlpha(0.5, 1), UIControlState.Normal);
button.setTranslatesAutoresizingMaskIntoConstraints(false);
button.addOnTouchUpInsideListener(new UIControl.OnTouchUpInsideListener() {
@Override
public void onTouchUpInside(UIControl control, UIEvent event) {
dismissViewController(true, null);
}
});
view.addSubview(button);
// Layout
Map<String, NSObjectProtocol> views = new HashMap<>();
views.put("parent", view);
views.put("title", titleLabel);
views.put("done", button);
view.addConstraints(NSLayoutConstraint.createConstraints("H:[parent]-(<=1)-[title]",
NSLayoutFormatOptions.AlignAllCenterY, null, views));
view.addConstraints(NSLayoutConstraint.createConstraints("V:[parent]-(<=1)-[title]-33-[done]",
NSLayoutFormatOptions.AlignAllCenterX, null, views));
}
示例9: 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;
}
示例10: PAPBaseTextCell
import org.robovm.apple.uikit.UILabel; //导入方法依赖的package包/类
public PAPBaseTextCell(UITableViewCellStyle style, String reuseIdentifier) {
super(style, reuseIdentifier);
setClipsToBounds(true);
horizontalTextSpace = PAPBaseTextCell.getHorizontalTextSpaceForInsetWidth(cellInsetWidth);
setOpaque(true);
setSelectionStyle(UITableViewCellSelectionStyle.None);
setAccessoryType(UITableViewCellAccessoryType.None);
setBackgroundColor(UIColor.clear());
mainView = new UIView(getContentView().getFrame());
mainView.setBackgroundColor(UIColor.white());
avatarImageView = new PAPProfileImageView();
avatarImageView.setBackgroundColor(UIColor.clear());
avatarImageView.setOpaque(true);
avatarImageView.getLayer().setCornerRadius(16);
avatarImageView.getLayer().setMasksToBounds(true);
mainView.addSubview(avatarImageView);
nameButton = new UIButton(UIButtonType.Custom);
nameButton.setBackgroundColor(UIColor.clear());
if (reuseIdentifier.equals("ActivityCell")) {
nameButton.setTitleColor(UIColor.white(), UIControlState.Normal);
nameButton.setTitleColor(UIColor.fromRGBA(114f / 255f, 114f / 255f, 114f / 255f, 1),
UIControlState.Highlighted);
} else {
nameButton.setTitleColor(UIColor.fromRGBA(34f / 255f, 34f / 255f, 34f / 255f, 1), UIControlState.Normal);
nameButton.setTitleColor(UIColor.fromRGBA(114f / 255f, 114f / 255f, 114f / 255f, 1),
UIControlState.Highlighted);
}
nameButton.getTitleLabel().setFont(UIFont.getBoldSystemFont(13));
nameButton.getTitleLabel().setLineBreakMode(NSLineBreakMode.TruncatingTail);
nameButton.addOnTouchUpInsideListener(didTapUserButton);
mainView.addSubview(nameButton);
contentLabel = new UILabel();
contentLabel.setFont(UIFont.getSystemFont(13));
if (reuseIdentifier.equals("ActivityCell")) {
contentLabel.setTextColor(UIColor.white());
} else {
contentLabel.setTextColor(UIColor.fromRGBA(34f / 255f, 34f / 255f, 34f / 255f, 1));
}
contentLabel.setNumberOfLines(0);
contentLabel.setLineBreakMode(NSLineBreakMode.WordWrapping);
contentLabel.setBackgroundColor(UIColor.clear());
mainView.addSubview(contentLabel);
timeLabel = new UILabel();
timeLabel.setFont(UIFont.getSystemFont(11));
timeLabel.setTextColor(UIColor.fromRGBA(114f / 255f, 114f / 255f, 114f / 255f, 1));
timeLabel.setBackgroundColor(UIColor.clear());
mainView.addSubview(timeLabel);
avatarImageButton = new UIButton(UIButtonType.Custom);
avatarImageButton.setBackgroundColor(UIColor.clear());
avatarImageButton.addOnTouchUpInsideListener(didTapUserButton);
mainView.addSubview(avatarImageButton);
separatorImage = new UIImageView(UIImage.getImage("SeparatorComments").newResizableImage(
new UIEdgeInsets(0, 1, 0, 1)));
getContentView().addSubview(mainView);
}
示例11: PAPFindFriendsCell
import org.robovm.apple.uikit.UILabel; //导入方法依赖的package包/类
public PAPFindFriendsCell(UITableViewCellStyle style, String reuseIdentifier) {
super(style, reuseIdentifier);
setBackgroundColor(UIColor.black());
setSelectionStyle(UITableViewCellSelectionStyle.None);
avatarImageView = new PAPProfileImageView(new CGRect(10, 14, 40, 40));
avatarImageView.getLayer().setCornerRadius(20);
avatarImageView.getLayer().setMasksToBounds(true);
getContentView().addSubview(avatarImageView);
avatarImageButton = new UIButton(UIButtonType.Custom);
avatarImageButton.setBackgroundColor(UIColor.clear());
avatarImageButton.setFrame(new CGRect(10, 14, 40, 40));
avatarImageButton.addOnTouchUpInsideListener(didTapUserButton);
getContentView().addSubview(avatarImageButton);
nameButton = new UIButton(UIButtonType.Custom);
nameButton.setBackgroundColor(UIColor.clear());
nameButton.getTitleLabel().setFont(UIFont.getBoldSystemFont(16));
nameButton.getTitleLabel().setLineBreakMode(NSLineBreakMode.TruncatingTail);
nameButton.setTitleColor(UIColor.white(), UIControlState.Normal);
nameButton
.setTitleColor(UIColor.fromRGBA(114f / 255f, 114f / 255f, 114f / 255f, 1), UIControlState.Highlighted);
nameButton.addOnTouchUpInsideListener(didTapUserButton);
getContentView().addSubview(nameButton);
photoLabel = new UILabel();
photoLabel.setFont(UIFont.getSystemFont(11));
photoLabel.setTextColor(UIColor.gray());
photoLabel.setBackgroundColor(UIColor.clear());
getContentView().addSubview(photoLabel);
followButton = new UIButton(UIButtonType.Custom);
followButton.getTitleLabel().setFont(UIFont.getBoldSystemFont(15));
followButton.setTitleEdgeInsets(new UIEdgeInsets(0, 10, 0, 0));
followButton.setBackgroundImage(UIImage.getImage("ButtonFollow"), UIControlState.Normal);
followButton.setBackgroundImage(UIImage.getImage("ButtonFollowing"), UIControlState.Selected);
followButton.setImage(UIImage.getImage("IconTick"), UIControlState.Selected);
followButton.setTitle("Follow ", UIControlState.Normal);
followButton.setTitle("Following", UIControlState.Selected);
followButton.setTitleColor(UIColor.fromRGBA(254f / 255f, 149f / 255f, 50f / 255f, 1), UIControlState.Normal);
followButton.setTitleColor(UIColor.white(), UIControlState.Selected);
followButton.addOnTouchUpInsideListener(didTapFollowButton);
getContentView().addSubview(followButton);
}
示例12: PAPPhotoHeaderView
import org.robovm.apple.uikit.UILabel; //导入方法依赖的package包/类
/**
* Initializes the view with the specified interaction elements.
*
* @param buttons A bitmask specifying the interaction elements which are
* enabled in the view
*/
public PAPPhotoHeaderView(CGRect frame, PAPPhotoHeaderButtons otherButtons) {
super(frame);
validateButtons(otherButtons);
this.buttons = otherButtons;
setClipsToBounds(false);
setBackgroundColor(UIColor.clear());
// translucent portion
containerView = new UIView(
new CGRect(0, 0, getBounds().getSize().getWidth(), getBounds().getSize().getHeight()));
containerView.setClipsToBounds(false);
addSubview(containerView);
containerView.setBackgroundColor(UIColor.white());
avatarImageView = new PAPProfileImageView(new CGRect(4, 4, 35, 35));
avatarImageView.getProfileButton().addOnTouchUpInsideListener(didTapUserButton);
containerView.addSubview(avatarImageView);
if (buttons.contains(PAPPhotoHeaderButton.Comment)) {
commentButton = new UIButton(UIButtonType.Custom);
containerView.addSubview(commentButton);
commentButton.setFrame(new CGRect(282, 10, 29, 29));
commentButton.setBackgroundColor(UIColor.clear());
commentButton.setTitle("", UIControlState.Normal);
commentButton.setTitleColor(UIColor.fromRGBA(254f / 255f, 149f / 255f, 50f / 255f, 1),
UIControlState.Normal);
commentButton.setTitleEdgeInsets(new UIEdgeInsets(-6, 0, 0, 0));
commentButton.getTitleLabel().setFont(UIFont.getSystemFont(12));
commentButton.getTitleLabel().setMinimumScaleFactor(0.8);
commentButton.getTitleLabel().setAdjustsFontSizeToFitWidth(true);
commentButton.setBackgroundImage(UIImage.getImage("IconComment"), UIControlState.Normal);
commentButton.setSelected(false);
}
if (buttons.contains(PAPPhotoHeaderButton.Like)) {
likeButton = new UIButton(UIButtonType.Custom);
containerView.addSubview(likeButton);
likeButton.setFrame(new CGRect(246, 9, 29, 29));
likeButton.setBackgroundColor(UIColor.clear());
likeButton.setTitle("", UIControlState.Normal);
likeButton.setTitleColor(UIColor.fromRGBA(254f / 255f, 149f / 255f, 50f / 255f, 1), UIControlState.Normal);
likeButton.setTitleColor(UIColor.white(), UIControlState.Selected);
likeButton.setTitleEdgeInsets(new UIEdgeInsets(0, 0, 0, 0));
likeButton.getTitleLabel().setFont(UIFont.getSystemFont(12));
likeButton.getTitleLabel().setMinimumScaleFactor(0.8);
likeButton.getTitleLabel().setAdjustsFontSizeToFitWidth(true);
likeButton.setAdjustsImageWhenHighlighted(false);
likeButton.setAdjustsImageWhenDisabled(false);
likeButton.setBackgroundImage(UIImage.getImage("ButtonLike"), UIControlState.Normal);
likeButton.setBackgroundImage(UIImage.getImage("ButtonLikeSelected"), UIControlState.Normal);
likeButton.setSelected(false);
}
if (buttons.contains(PAPPhotoHeaderButton.User)) {
// This is the user's display name, on a button so that we can tap
// on it
userButton = new UIButton(UIButtonType.Custom);
containerView.addSubview(userButton);
userButton.setBackgroundColor(UIColor.clear());
userButton.getTitleLabel().setFont(UIFont.getBoldSystemFont(15));
userButton.setTitleColor(UIColor.fromRGBA(34f / 255f, 34f / 255f, 34f / 255f, 1), UIControlState.Normal);
userButton.setTitleColor(UIColor.black(), UIControlState.Highlighted);
userButton.getTitleLabel().setLineBreakMode(NSLineBreakMode.TruncatingTail);
}
timeFormatter = new TTTTimeIntervalFormatter();
// timestamp
timestampLabel = new UILabel(new CGRect(50, 24, containerView.getBounds().getSize().getWidth() - 50 - 72, 18));
containerView.addSubview(timestampLabel);
timestampLabel.setTextColor(UIColor.fromRGBA(114f / 255f, 114f / 255f, 114f / 255f, 1));
timestampLabel.setFont(UIFont.getSystemFont(11));
timestampLabel.setBackgroundColor(UIColor.clear());
}
示例13: viewDidLoad
import org.robovm.apple.uikit.UILabel; //导入方法依赖的package包/类
@Override
public void viewDidLoad() {
super.viewDidLoad();
getTableView().setSeparatorStyle(UITableViewCellSeparatorStyle.None);
getTableView().setBackgroundColor(UIColor.black());
getNavigationItem().setTitleView(new UIImageView(UIImage.getImage("TitleFindFriends")));
if (getNavigationController().getViewControllers().first() == this) {
UIBarButtonItem dismissLeftBarButtonItem = new UIBarButtonItem("Back", UIBarButtonItemStyle.Plain,
new UIBarButtonItem.OnClickListener() {
@Override
public void onClick(UIBarButtonItem barButtonItem) {
getNavigationController().dismissViewController(true, null);
}
});
getNavigationItem().setLeftBarButtonItem(dismissLeftBarButtonItem);
} else {
getNavigationItem().setLeftBarButtonItem(null);
}
if (MFMailComposeViewController.canSendMail() || MFMessageComposeViewController.canSendText()) {
headerView = new UIView(new CGRect(0, 0, 320, 67));
headerView.setBackgroundColor(UIColor.black());
UIButton clearButton = new UIButton(UIButtonType.Custom);
clearButton.setBackgroundColor(UIColor.clear());
clearButton.addOnTouchUpInsideListener(inviteFriendsButtonAction);
clearButton.setFrame(headerView.getFrame());
headerView.addSubview(clearButton);
String inviteString = "Invite friends";
CGRect boundingRect = NSString.getBoundingRect(inviteString, new CGSize(310, Float.MAX_VALUE),
NSStringDrawingOptions.with(NSStringDrawingOptions.TruncatesLastVisibleLine,
NSStringDrawingOptions.UsesLineFragmentOrigin),
new NSAttributedStringAttributes().setFont(UIFont.getBoldSystemFont(18)), null);
CGSize inviteStringSize = boundingRect.getSize();
UILabel inviteLabel = new UILabel(new CGRect(10,
(headerView.getFrame().getSize().getHeight() - inviteStringSize.getHeight()) / 2,
inviteStringSize.getWidth(), inviteStringSize.getHeight()));
inviteLabel.setText(inviteString);
inviteLabel.setFont(UIFont.getBoldSystemFont(18));
inviteLabel.setTextColor(UIColor.white());
inviteLabel.setBackgroundColor(UIColor.clear());
headerView.addSubview(inviteLabel);
getTableView().setTableHeaderView(headerView);
}
}
示例14: 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);
}
示例15: MyOverlayViewController
import org.robovm.apple.uikit.UILabel; //导入方法依赖的package包/类
public MyOverlayViewController(final MyMovieViewController movieViewController) {
UIView view = getView();
view.setFrame(new CGRect(0, 0, 123, 57));
view.setAlpha(0.8);
view.setBackgroundColor(UIColor.fromWhiteAlpha(0.33, 1));
closeButton = new UIButton(UIButtonType.RoundedRect);
closeButton.setFrame(new CGRect(26, 32, 74, 18));
closeButton.setTitle("Close Movie", UIControlState.Normal);
closeButton.setTitleColor(UIColor.white(), UIControlState.Highlighted);
closeButton.getTitleLabel().setFont(UIFont.getSystemFont(11));
closeButton.addOnTouchUpInsideListener(new UIControl.OnTouchUpInsideListener() {
@Override
public void onTouchUpInside(UIControl control, UIEvent event) {
movieViewController.closeOverlay();
}
});
view.addSubview(closeButton);
UILabel playStateLabel = new UILabel(new CGRect(8, 15, 51, 15));
playStateLabel.setText("Play State:");
playStateLabel.setTextColor(UIColor.darkText());
playStateLabel.setFont(UIFont.getSystemFont(9));
view.addSubview(playStateLabel);
moviePlaybackStateText = new UILabel(new CGRect(57, 18, 62, 11));
moviePlaybackStateText.setTextColor(UIColor.darkText());
moviePlaybackStateText.setContentMode(UIViewContentMode.Left);
moviePlaybackStateText.setFont(UIFont.getSystemFont(9));
moviePlaybackStateText.setLineBreakMode(NSLineBreakMode.TruncatingTail);
view.addSubview(moviePlaybackStateText);
UILabel loadStateLabel = new UILabel(new CGRect(5, 3, 51, 15));
loadStateLabel.setText("Load State:");
loadStateLabel.setTextColor(UIColor.darkText());
loadStateLabel.setFont(UIFont.getSystemFont(9));
view.addSubview(loadStateLabel);
movieLoadStateText = new UILabel(new CGRect(57, 6, 62, 11));
movieLoadStateText.setTextColor(UIColor.darkText());
movieLoadStateText.setContentMode(UIViewContentMode.Left);
movieLoadStateText.setFont(UIFont.getSystemFont(9));
movieLoadStateText.setLineBreakMode(NSLineBreakMode.TruncatingTail);
view.addSubview(movieLoadStateText);
}