Tag: 自定义控件

自定义rightBarButtonItem消失

我在NavBar中有一个自定义的RightBarButtomItem的奇怪的错误。 我有一个TabBar应用程序。 如果该应用程序已加载button显示正确。 如果我点击标签button不断显示。 如果我回到已经显示的标签之一,button消失。 最后,button只在其中一个标签中随机显示。 我的代码完美工作,如果我设置一个标准的rightBarButtomItem编程。 但不是自定义graphics。 如果一个ChildViewController被按下并popup,该button再次出现。 它似乎仍然存在但不可见! 我认为我在CustomTabBarViewController中的sharedRightButton的引用是错误的! 任何人都可以帮忙吗? CustomTabBarController.h #import <UIKit/UIKit.h> #import "EZBadgeView.h" @interface CustomTabBarController : UITabBarController { EZBadgeView *badgeView; UIButton *btn; UIImage *rightBarButtonItemImage; UIImage *rightBarButtonItemImageTapped; UIImage *rightBarButtonItemImageSelected; } @property (nonatomic, strong) UIBarButtonItem *sharedRightButton; @property (nonatomic, strong) EZBadgeView *badgeView; @property(nonatomic, strong) UIButton *btn; @property(nonatomic, strong) UIImage *rightBarButtonItemImage; @property(nonatomic, strong) UIImage *rightBarButtonItemImageTapped; […]

Xamarin – 带有绝对布局的文本和图像的button导致错误alignment的元素

我正在尝试在Xamarin Forms跨平台的应用程序(iOS和Android)中创build一个button,其中button同时具有文本和图像。 XAML非常简单: <AbsoluteLayout …> <Labels and backgrounds and such> <Button x:Name="HomeButton2" TranslationX="6" TranslationY="100" BackgroundColor="#efeff4" TextColor="#4a4a4a" WidthRequest="58" HeightRequest="76" ContentLayout="Top,5" Image="TaskBar_Assets_HomeButtonIcon.png" Text="Home" Clicked="HomeButton_Clicked" /> </AbsoluteLayout> 但是我在iPad上得到的是一个button,图像和文本都被奇怪地推到了一边: (源图像“TaskBar_Assets_HomeButtonIcon.png”是47 x 44,所以它应该适合在整个button区域罚款) 我可以find使这看起来更好的唯一方法是制作一个基于Button的自定义控件,然后我可以看到底层的UIButton的几个属性看起来不可思议: Control.ImageView.Frame是全零: Control.ImageView = <UIImageView: 0x12df52940; frame = (0 0; 0 0); clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x173623180>> Control.ImageEdgeInsets和.TitleEdgeInsets看起来很奇怪(右边+左边看起来好像没有为图像或文本留下空间): Control.ImageEdgeInsets […]

Swift可重用的UITextFieldDelegate

我想实现一个可重用的UITextFieldDelegate类,如下所示: class CustomTextFieldDelegate : NSObject, UITextFieldDelegate 所有委托协议方法都正确实施。 在controller ,我将delegate分配给UITextField textField.delegate = CustomTextFieldDelegate() 问题是没有任何委托函数被调用。 但是,当我从控制器实施委托协议,然后事情工作正常 class CustomTableViewController: UITableViewController, UITextFieldDelegate 任何想法是怎么回事?

iOS无状态/无价值进度条?

我期待在iOS中获得无状态/无价值的UIProgressView或其他types的进度条: 我试过查找一些文档,但找不到与我的问题相关的任何内容。 如果你有任何build议,我很想听到那些:) 谢谢! 夏嘉曦。

自定义PopOver模式边框

我试图实现像这样的popover: 我花了相当多的时间试图定制UIPopoverController和UIPopoverBackgroundView 。 据我所知,我的任务是不可能与公共API的popup。 有可能的: 要使用固定的angular落和可拉伸的中心的小图像,在这种情况下,我会在侧面拉长条纹。 而且我会在箭头下面有图像。 用条纹填充边框,但在这种情况下,我没有圆angular。 我内心也有烦人的内心阴影: backgroundImageView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@“airmail_pattern”]]; 有没有其他的方式来重用标准的弹窗或我只需要使用UIViewController来实现该行为? 干杯。

iPhone / iOS自定义控件

我想知道如何从头创build一个自定义的iPhone控件,或使用现有的库或框架。 我已经看到了three20图书馆,以及tapku和触摸习惯,这是专业的iOS控制,如表视图等不错,但我在这里谈论完全自定义,交互式控制。 比方说,我想做一个类似于这个应用程序的拨号控制: http : //store.apple.com/us/product/H2654LL/A 。 我从哪里开始? 我会inheritanceUIView并定制它吗? 我会用石英2d吗? 我会用OpenGL ES来画这样的东西到屏幕上吗? 我仍然可以使用IB来devise/布置我的自定义视图吗? 我只是有点困惑到哪里去这里。 是的 – 这个问题已经被问及过几次了,但是我还没有find满意的答案来解决上述问题。

UIAlertController中的自定义视图

我正在尝试在UIAlertController放置一个自定义视图。 我遇到了一些与自定义视图大小有关的奇怪问题。 我想要自定义视图跨越UIAlertController的宽度,无论可能。 我正在使用CGRectGetWidth(alertController.view.bounds)来获取警报控制器的宽度。 但是,这似乎是返回整个视图的宽度。 使用view.frame没有什么区别。 UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"My Title" message:nil preferredStyle:UIAlertControllerStyleAlert]; UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(alertController.view.bounds), 50)]; view.backgroundColor = [UIColor blueColor]; [alertController.view addSubview:view]; [self presentViewController:alertController animated:YES completion:nil]; 这产生了下面的结果。 我有相同的问题,试图获得UIAlertController X,Y宽度和高度属性。 有没有人知道我怎么可以不使用硬编码的数字位于警报控制器的中间这个观点?

在CustomUIView中覆盖init()崩溃应用程序(EXC_BAD ACCESS)

我想在Swift中inheritance一个UIView。 当初始化程序被调用时,应用程序崩溃(EXC_BAD_ACCESS) 这是class级 class CustomActionSheet: UIView { private var cancelButtonTitle: String!; private var destructiveButtonTitle: String!; private var otherButtonTitles: [String]!; convenience init() { self.init();//EXC_BAD_ACCESS } required init(coder aDecoder: NSCoder) { super.init(coder: aDecoder); } convenience init(cancelButtonTitle: String!, destructiveButtonTitle: String!, otherButtonTitles: [String]!) { self.init(); self.cancelButtonTitle = cancelButtonTitle; self.destructiveButtonTitle = destructiveButtonTitle; self.otherButtonTitles = otherButtonTitles; prepareUI(); } func prepareUI() { […]

自定义button框架看起来不如Round Rect UIButton

我试图画一个自定义的button框架如下: UIBezierPath *stroke = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:RECT_CORNECR_RADIUS]; [stroke stroke]; 但由于某种原因,angular落的曲线看起来比两边思考。 如果你看看UIButton的默认框架,它是非常统一的。 A是一个UIButton,B是一个自定义button。 任何想法,我可以使它更像UIButton。

使用启用的Storyboard自动布局function,无法在iOS6中自定义UIButton

我面对奇怪的行为。 我正在使用自定义样式的button,我在我的控制器中设置: – (void)viewDidLoad { [super viewDidLoad]; [self.signOutButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [self.signOutButton setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted]; CAGradientLayer *btnGradient = [CAGradientLayer layer]; btnGradient.frame = self.signOutButton.bounds; btnGradient.colors = [NSArray arrayWithObjects: (id)[[UIColor colorWithRed:102.0f / 255.0f green:102.0f / 255.0f blue:102.0f / 255.0f alpha:1.0f] CGColor], (id)[[UIColor colorWithRed:51.0f / 255.0f green:51.0f / 255.0f blue:51.0f / 255.0f alpha:1.0f] CGColor], nil]; [self.signOutButton.layer insertSublayer:btnGradient atIndex:0]; […]