复制Twitterrific样式警报

时间:2013-07-03 09:14:13

标签: iphone ios uiviewcontroller uialertview uistoryboard

enter image description here

我正在尝试复制中间的屏幕,即显示组成新推文的警报。我试图用自定义UIAlertView复制它,但这需要大量的子类化,什么不是,然后我怀疑它可能只是一个简单的UIViewController显示在主视图上...专业需要来自iOS开发人员的想法。

谢谢。

1 个答案:

答案 0 :(得分:1)

在iPad中

您可以使用UIViewController

  • 您需要根据上面的图像设计UI。
  • 然后您需要将模态演示文稿样式设置为UIModalPresentationFormSheet
  • 使用- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))
  • 呈现它

像:

UIViewController *viewC = [[UIViewController alloc] init];
viewC.view.frame = //set the frame;
viewC.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:viewC animated:YES completion:nil];

在iPhone中:

您可以使用UIView

来完成

您可以使用以下代码执行此操作:

在您的界面中声明属性

@property (nonatomic, strong) UIView *views;

//添加视图

- (void) showView
{
   UIToolbar *toolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 35)];
        UIBarButtonItem *bar = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(remove)];
        toolbar.items = [NSArray arrayWithObject:bar];
        _views = [[UIView alloc] initWithFrame:CGRectMake(0, -300, self.view.bounds.size.width, self.view.bounds.size.height/3)];
        [_views addSubview:toolbar];
        [_views setBackgroundColor:[UIColor grayColor]];
        [self.view addSubview:_views];
        [UIView animateWithDuration:0.7
                              delay:0.0
                            options:UIViewAnimationCurveLinear
                         animations:^{

                             _views.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height/3);
                         }
                         completion:^(BOOL yes){
                             NSLog(@"YO");

                         }];
        [UIView commitAnimations];
}

//删除视图

- (void)remove
{
    [UIView animateWithDuration:0.7
                          delay:0.0
                        options:UIViewAnimationCurveLinear
                     animations:^{
                         _views.frame = CGRectMake(0, -500, self.view.bounds.size.width, self.view.bounds.size.height/3);
                     }
                     completion:^(BOOL yes){
                         NSLog(@"YA");

                     }];
    [UIView commitAnimations];
}