标签: uitabbaritem

点击 UITabBarItem 可像 Instagram 和 Twitter 一样滚动到顶部

我在使用此功能时遇到问题,希望获得一些帮助。

我的层次结构是TabBarController-> Navigation Controller->TableViewController

我想要的是,如果您在当前选项卡上并且向下滚动,您将能够点击当前视图,UITabBarItem并且您将滚动回顶部,就像 Instagram 和 Twitter 那样。

我在这里尝试了很多事情:

较旧的问题

但遗憾的是,没有一个答案适合我。

我真的很感激任何有关这种方式的帮助,提前谢谢您!

这是我的 TableView`控制器的代码:

import UIKit

class BarsViewController: UITableViewController,UISearchResultsUpdating,UISearchBarDelegate,UISearchDisplayDelegate,UITabBarControllerDelegate{

//TableView Data & non related stuff....

override func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
        self.searchController.searchBar.resignFirstResponder()
        self.searchController.searchBar.endEditing(true)
    }

 func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
        let tabBarIndex = tabBarController.selectedIndex
        if tabBarIndex == 0 {

            let indexPath = IndexPath(row: 0, section: 0)
            let navigVC = viewController as? UINavigationController
            let finalVC = navigVC?.viewControllers[0] as? BarsViewController
            finalVC?.tableView.scrollToRow(at: indexPath as …
Run Code Online (Sandbox Code Playgroud)

uitableview uitabbaritem scrolltop ios swift

5
推荐指数
1
解决办法
6689
查看次数

iOS 在 UITabBarController 中的 UIMoreNavigationController 中更改徽章颜色

我使用以下代码自定义背景颜色及其色调:

var blackBGColor = new UIColor(new nfloat(40) / 255f,
                               new nfloat(40) / 255f,
                               new nfloat(40) / 255f, 1f);

this.MoreNavigationController.TopViewController.View.BackgroundColor = blackBGColor;

var moreTableView = (UITableView)this.MoreNavigationController.TopViewController.View;
moreTableView.TintColor = UIColor.White;
foreach (var cell in moreTableView.VisibleCells)
{
     cell.BackgroundColor = blackBGColor;
     cell.TextLabel.TextColor = UIColor.White;
     var selectedView = new UIView
     {
          BackgroundColor = UIColor.DarkGray
     };
     cell.SelectedBackgroundView = selectedView;
}

this.MoreNavigationController.NavigationBar.BarStyle = UIBarStyle.Black;
this.MoreNavigationController.NavigationBar.Translucent = false;
this.MoreNavigationController.NavigationBar.TintColor = UIColor.White;
this.MoreNavigationController.NavigationBar.BarTintColor = new UIColor(24f / 255f, 24f / 255f, 24f / 255f, 1f);
Run Code Online (Sandbox Code Playgroud)

但我无法改变里面的徽章颜色UIMoreNavigationController

我试过这个: …

c# uitabbarcontroller uitabbaritem xamarin.ios

5
推荐指数
1
解决办法
410
查看次数

如何在 UITabBarItem 中垂直居中 SF Symbols 图像?

我在我的 iOS 应用程序中使用 SF Symbols 图像作为标签图像,方法如下:

self.tabBarItem.image = UIImage(systemName: "ellipsis")  
Run Code Online (Sandbox Code Playgroud)

这导致所有图像顶部对齐,但我希望它们垂直居中。

我该怎么做?

uikit uitabbaritem uitabbar ios sf-symbols

5
推荐指数
2
解决办法
1475
查看次数

SwiftUI 标签栏颜色

如何设置标签栏颜色?例如,仅使用灰色条分配黑色结果。这是针对 SwiftUI 的。指定暗模式不是一个合适的解决方法。

截屏

    struct ContentView: View {

    @State private var selection = 1



    init() {
        UITabBar.appearance().backgroundColor = UIColor.blue 
        UITabBar.appearance().backgroundImage = UIImage()
        //UITabBar.appearance().isTranslucent = false
        //UITabBar.appearance().shadowImage = UIImage()

    }

    var body: some View {

        TabView {
            ClockView()
                .tabItem {
                    Image("clock")
                    Text("Clock")
            }.tag(0)
            PlanetsNowView()
                .tabItem {
                    Image("clock")
                    Text("Now")
            }.tag(1)
            SettingsView()
                .tabItem {
                    Image("settings")
                    Text("Settings")
            }.tag(2)
        }
        .accentColor(.white)
        .opacity(1)
        //.environment(\.colorScheme, .dark)
    }
}
Run Code Online (Sandbox Code Playgroud)

uitabbaritem swiftui

5
推荐指数
2
解决办法
5407
查看次数

UITabBarAppearance 在 iOS15 iPad 上不起作用(标题颜色)

我创建了一个简单的演示,仅创建了 UITabBarController 的子类并在故事板中设置。

我想在选择时将 TabBarButtonItem 的标题设置为橙色,在正常情况下将标题设置为黑色。以下代码在 iPhone 上的任何 iOS 版本上都可以正常工作,但在 iOS 15 的 iPad(设备和模拟器)上,所选颜色更改为蓝色和有线正常状态颜色。

这是苹果的错误还是我错过了什么?(我使用的是 Xcode13)

class CustomViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let tabBarAppearnace = UITabBarAppearance()
        let tabFont =  UIFont.boldSystemFont(ofSize: 18)
        
        let selectedAttributes: [NSAttributedString.Key: Any]
        = [NSAttributedString.Key.font: tabFont, NSAttributedString.Key.foregroundColor: UIColor.orange]
        let normalAttributes: [NSAttributedString.Key: Any]
        = [NSAttributedString.Key.font: tabFont, NSAttributedString.Key.foregroundColor: UIColor.black]
        
        tabBarAppearnace.stackedLayoutAppearance.normal.titleTextAttributes = normalAttributes
        tabBarAppearnace.stackedLayoutAppearance.selected.titleTextAttributes = selectedAttributes
        
        tabBar.standardAppearance = tabBarAppearnace
    }
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

uitabbaritem ios swift ios15

5
推荐指数
1
解决办法
2441
查看次数

由于 .accentColor 已弃用,如何在 SwiftUI 中正确设置 TabBarIcon 颜色?

在 SwiftUI 中更改所选内容的颜色似乎相当困难UITabBarItem。为了在应用程序的中心位置定义设计,我尝试.appearance()这样做,但没有任何效果:

// Only effects the unselected items
UITabBar.appearance().unselectedItemTintColor = .red

// No effect, deprecated in iOS 8(!)
UITabBar.appearance().selectedImageTintColor = .cyan

// Only effects the title, not the icon 
UITabBarItem.appearance().setTitleTextAttributes([.foregroundColor: UIColor.green], for: .normal)

// No effect
UITabBar.appearance().tintColor = .red
Run Code Online (Sandbox Code Playgroud)

View唯一有效的方法是不使用外观代理,而是使用SwiftUI 定义中的“手动”设置颜色.accentColor

struct MainView: View {
    var body: some View {
        TabView {
             SomeView()
                .tabItem {
                    Label("Main", systemImage: "list.dash")
                        .tint(.green) // No effect
                }
                .tint(.yellow) // No effect
        }
        .accentColor(.orange)
        
        // No effect
        //.tint(.red) …
Run Code Online (Sandbox Code Playgroud)

uitabbaritem uitabbar ios swiftui

5
推荐指数
0
解决办法
201
查看次数

本机UITabBarItem上使用的字体设置是什么

我正在尝试复制UITabBarItem上使用的天真字体设置,以便在自定义标签栏上使用.

有谁知道字体设置是什么?什么UIFont,字体大小,文字颜色等......?

fonts uitabbaritem

4
推荐指数
1
解决办法
2689
查看次数

删除TabBar按钮发光(不在图像上 - 隐藏按钮的选择色调)

我创建了一个tabbar应用程序,我使用带有backGround图像的自定义TabBar.我已完成所有部件,但无法在点击时移除tabbar按钮的光晕(我只是在点击时更改UIButton选项,但仍然存在发光)

如何隐藏UITabBar按钮的光晕(即隐藏按钮的选择色调)?

现在TabBar是这样的..

需要tabBar这样的

objective-c uitabbarcontroller uitabbaritem ios

4
推荐指数
1
解决办法
3443
查看次数

Tabbar项目图像不会出现

我对tabbar项目的图像有问题.我在每个tabbar项目上设置了一个图像,但是当我运行应用程序时,出现的唯一图像是第一个tabbar项目的图像.在我选择其中一个选项卡之前,其他标签栏项目的图像不会显示.我用来在tabbar项目上设置图像的代码如下:

[self.tabBarItem setImage:[UIImage imageNamed:@"multi30x30.png"]];

[self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"multi30x30.png"]
              withFinishedUnselectedImage:[UIImage imageNamed:@"multi30x30.png"]];
Run Code Online (Sandbox Code Playgroud)

有人能帮我吗?

objective-c uitabbarcontroller uitabbaritem ios

4
推荐指数
1
解决办法
9540
查看次数

在故事板中设置UITabBarItem图像,但在运行应用程序时不同

1)我在Assets.xcassets中添加了四个png图像. 选中的图像

正常的形象

2)在故事板中,我嵌入了一个标签栏控制器.设置TabBarItem图像. 故事板设置

3)但运行应用程序后.我发现图像看起来与我的设置有点不同,我不知道为什么,谁能知道为什么以及如何修复?等你帮忙,谢谢 在此输入图像描述

uitabbaritem ios

4
推荐指数
1
解决办法
1113
查看次数