从obj-c转换为swift

阳光明媚的k

我是iOS的新手,很快。

我正在尝试实现SherginScrollableNavigationBar

这是其演示项目中的代码:

#import "SherginNavigationTableViewController.h"

#import "SherginScrollableNavigationBar.h"

@interface SherginNavigationTableViewController ()

@end

@implementation SherginNavigationTableViewController

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    // SherginScrollableNavigationBar
    ((SherginScrollableNavigationBar *)self.navigationController.navigationBar).scrollView = self.tableView;

    self.title = @"ScrollableNavigationBar";
}

- (void)viewDidDisappear:(BOOL)animated
{
    // SherginScrollableNavigationBar
    ((SherginScrollableNavigationBar *)self.navigationController.navigationBar).scrollView = self.tableView;

    [super viewDidDisappear:animated];
}

@end

有人可以帮我将这段代码转换为swift吗?

怀特罗

您应该检查一下Objectivec2swift.net

将其转换为:

    import "SherginNavigationTableViewController.h"
    import "SherginScrollableNavigationBar.h"

    class SherginNavigationTableViewController {
        func initWithStyle(style: UITableViewStyle) -> AnyObject {
            self = super(style: style)
            if self {
            // Custom initialization
            }
            return self
        }

        func viewWillAppear(animated: Bool) {
            super.viewWillAppear(animated)
            // SherginScrollableNavigationBar
           (self.navigationController.navigationBar as 
           SherginScrollableNavigationBar).scrollView = self.tableView


            self.title = "ScrollableNavigationBar"
        }

        func viewDidDisappear(animated: Bool) {
                // SherginScrollableNavigationBar
                (self.navigationController.navigationBar as 
           SherginScrollableNavigationBar).scrollView = self.tableView
                super.viewDidDisappear(animated)
            }
        }

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章