Apple在iOS 7中的tabBar上添加了一条小线,它可以作为tabBar和UI之间的阴影或淡入淡出
因为我使用的是定制的tabBar,所以这条线很刺激.你怎么删除它?请告诉我这是可能的,否则我需要重新设计我的整个应用程序大声笑....
/ 问候
*编辑
使用以下代码行解决了我的问题:
[[UITabBar appearance] setShadowImage:[[UIImage alloc] init]];
Run Code Online (Sandbox Code Playgroud) 我正在创建一个自定义的UISlider并且想知道,如何增加拇指图像的"点击区域"?下面的代码效果很好,除了拇指的"点击区域"保持不变.如果我没错,我相信标准拇指面积是19像素?让我们说我想用下面的代码将它增加到35px,我需要采取哪些步骤?请记住,我根本不是这个领域的专家.
编辑 以下代码已更正并准备好复制意大利面!希望它能帮到你!
main.h
#import "MyUISlider.h"
@interface main : MLUIViewController <UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate, UIActionSheetDelegate, UIAlertViewDelegate, MFMailComposeViewControllerDelegate, UIGestureRecognizerDelegate, MLSearchTaskDelegate, MLDeactivateDelegate, MLReceiptDelegate>
{
..........
}
- (void)create_Custom_UISlider;
Run Code Online (Sandbox Code Playgroud)
的main.m
- (void)viewDidLoad
{
[self create_Custom_UISlider];
[self.view addSubview: customSlider];
}
- (void)create_Custom_UISlider
{
CGRect frame = CGRectMake(20.0, 320.0, 280, 0.0);
customSlider = [[MyUISlider alloc] initWithFrame:frame];
[customSlider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
// in case the parent view draws with a custom color or gradient, use a transparent color
customSlider.backgroundColor = [UIColor clearColor];
UIImage *stetchLeftTrack = [[UIImage imageNamed:@"blue_slider08.png"] …
Run Code Online (Sandbox Code Playgroud) 注意:问题解决了.
这是故事.我在我的项目中使用RevealViewController.我也隐藏了navigationBars:
[self.navigationController setNavigationBarHidden];
Run Code Online (Sandbox Code Playgroud)
我的项目可以在下面的图片中看到," menuButton "在tabBarViewController中实现.
由于我的界面外观导致navigationBar被隐藏,所有tabViews(HomeViewController)都不会显示menuButton和navigationBar.我没有使用panGestureRecognizer来触发菜单.
这意味着我有问题通过HomeViewController中的普通按钮触发菜单.menuButton事件放在tabBarViewController.m中:
_menuButton.target = self.revealViewController;
_menuButton.action = @selector(revealToggle:);
Run Code Online (Sandbox Code Playgroud)
所以我试着从HomeViewController调用一个方法来激活tabBarViewController中的按钮,如下所示:
HomeViewController.m
- (IBAction) onMenuClicked: (id)sender{
tabBar = [[tabBarViewController alloc] init];
[tabBar setupMenu]:
}
Run Code Online (Sandbox Code Playgroud)
tabBarViewController.m
-(void) setupMenu{
[_realMenuButton sendActionForControlEvents:UIControlEventTouchUpInside];
[_realMenuButton addTarget:self.revealViewController action:@selector(revealToggle:) UIControlEventTouchUpInside];
}
Run Code Online (Sandbox Code Playgroud)
在这个例子中,我尝试制作realMenuButton和普通的UIButton.香港专业教育学院还试图为刚的UIBarButtonItem触发@selector(revealToggle :)但是什么也没有发生在应用程序中,当我尝试触发来自HomeViewController按钮.
不知道我将如何使这项工作.还有其他想法或伎俩吗?如果有,请具体说明!问候
uinavigationbar uibutton uibarbuttonitem ios swrevealviewcontroller
我正在尝试使用其中的TextField完成我的UISearchBar的相同外观,就像在我的iOS 6应用程序中一样.我试图用几种方式编写代码但尚未成功.问题是,自iOS 7以来,我无法以任何方式更改TextField的框架.结果是,我的TextField占用了NavigationBar中的所有空间并覆盖了右边的UIBarButtonItem(菜单按钮).见下图:
截图http://oi44.tinypic.com/2ufewx0.jpg
iOS 6代码: 这是我在iOS 6中编码的方式,我可以将TextFields框架设置为我喜欢的任何内容!
UITextField *sbTextField = (UITextField *)[searchBar.subviews lastObject];
[sbTextField removeFromSuperview];
CGRect rect = searchBar.frame;
rect.size.height = 32;
rect.size.width = 210;
sbTextField.frame = rect;
[sbTextField setAutoresizingMask:UIViewAutoresizingFlexibleBottomMargin];
UIBarButtonItem *searchBarNavigationItem = [[UIBarButtonItem alloc] initWithCustomView:sbTextField];
[[self navigationItem] setLeftBarButtonItem:searchBarNavigationItem];
Run Code Online (Sandbox Code Playgroud)
iOS 7中上面代码的结果: [iOS 7外观]
iOS 7代码:iOS 7 的不同之处在于您需要使用子视图才能将UITextField添加到UISearchBar/UINavigationBar.通过这样做,我还没有能够改变它的框架.它目前与右侧的menuButton重叠,可以在下面的代码中看到...
UITextField* sbTextField;
CGRect rect = subView.frame;
rect.size.height = 32;
rect.size.width = 115;
for (UIView *subView in self.searchBar.subviews){
for (UIView *ndLeveSubView in subView.subviews){
if ([ndLeveSubView isKindOfClass:[UITextField class]])
{
sbTextField = (UITextField *)ndLeveSubView;
sbTextField.backgroundColor …
Run Code Online (Sandbox Code Playgroud) 下面是我的代码,用于处理我的应用程序actionBar/toolbar/tabBar和nestedScrollView以及其中的ViewPager(webView)的正确行为.ViewPager基本上是一个普通的webView.
除了我的ViewPager无法垂直滚动外,一切正常.仅滚动NestedScrollView.我想要与Facebook应用程序相同的行为,如果您滚动新闻源(webView),tabBar会垂直移动工具栏.
Run Code Online (Sandbox Code Playgroud)<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context=".ui.activity.FragmentContainer" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <android.support.v7.widget.Toolbar android:id="@+id/toolbar" app:theme="@style/M.Toolbar" app:popupTheme="@style/M.Toolbar.PopupTheme" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" app:layout_scrollFlags="scroll|enterAlways" > </android.support.v7.widget.Toolbar> <android.support.design.widget.TabLayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" app:tabMode="scrollable" android:visibility="gone" android:background="@color/background" app:background="@color/background" /> </android.support.design.widget.AppBarLayout> <android.support.v4.widget.NestedScrollView android:layout_height="match_parent" android:layout_width="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" android:background="@android:color/transparent" android:fillViewport="true" > <com.m.ui.util.EdgeScrollViewPager android:id="@+id/viewpager" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/transparent" android:visibility="visible" > </com.m.ui.util.EdgeScrollViewPager> </android.support.v4.widget.NestedScrollView> </android.support.design.widget.CoordinatorLayout>
所以为了能够滚动我的viewPager(webView),我添加了一个扩展webView的新类:
公共类TouchyWebView扩展WebView {
Run Code Online (Sandbox Code Playgroud)public TouchyWebView(Context context) { super(context); } public TouchyWebView(Context context, AttributeSet attrs) { super(context, attrs); } public TouchyWebView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); …
android-scrollview android-viewpager android-appbarlayout android-nestedscrollview
下面是我的应用程序用户界面的图片(actionBar / toolBar + webView +选项卡)。如您所见,AB /工具栏+选项卡是透明的(黑色,因此没有背景),但是它拒绝在背景中折叠到我的webView(EdgeScrollViewPager)上方。我在工具栏和tabBar中都将颜色设置为@null。我不知道该如何处理代码中的逻辑错误,即为什么actionBar / toolbar和tabBar不位于深蓝色背景(webView)之上。
app_bar_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.MainActivity">
<include layout="@layout/toolbar" />
<com.ui.util.EdgeScrollViewPager
android:id="@+id/content_main_viewpager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:visibility="visible"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
</com.ui.util.EdgeScrollViewPager>
<android.support.design.widget.TabLayout
android:id="@+id/content_main_tabs"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:tabMaxWidth="0dp"
app:tabGravity="fill"
app:tabMode="fixed"
app:tabTextAppearance="@style/ML.Tab"
app:tabPadding="0dp"
app:tabIndicatorHeight="0dp"
app:tabIndicatorColor="@null"
android:visibility="visible"
android:background="@null"
app:background="@null">
</android.support.design.widget.TabLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
工具栏
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
app:theme="@style/ML.Toolbar"
app:popupTheme="@style/ML.Toolbar.PopupTheme"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
>
<include layout="@layout/topbar_loading_indicator" />
</android.support.v7.widget.Toolbar>
Run Code Online (Sandbox Code Playgroud)
style.xml
<style name="ML.Toolbar" parent="@style/Widget.AppCompat.ActionBar">
<item name="android:background">@null</item>
<item name="background">@null</item>
<item name="android:windowActionBarOverlay">true</item> …
Run Code Online (Sandbox Code Playgroud) android transparent webview android-fragments android-actionbar
我有一个更通用的编码问题.
App shazam使用非常酷的设计,您可以在其中滑动图像.我想知道他们最有可能用什么类型的技术来创建它?我有兴趣为Android和iOS开发类似的东西.
网上可能有这样的教程或示例代码吗?至于我所看到的,在iOS/Android中没有像这样的设计的"原生"支持?所有经验都非常感谢./ 问候
在我的项目中,我通过ViewPager创建我的tabBar,如下所示:
MainActivity.java
mViewPager = (ViewPager) findViewById(R.id.content_main_viewpager);
if ( mViewPager != null ) {
final ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
adapter.addFragment( new LandingSearch(), "" );
adapter.addFragment( new LandingWiki(), "" );
adapter.addFragment( new LandingForum(), "" );
mViewPager.setAdapter(adapter);
mViewPager.setOffscreenPageLimit( 3 );
final TabLayout tabs = (TabLayout) findViewById(R.id.content_main_tabs);
if ( tabs != null ) {
tabs.post(new Runnable() {
@Override
public void run() {
tabs.setupWithViewPager( mViewPager );
tabs.getTabAt(0).setIcon(R.drawable.ic_tab_search);
tabs.getTabAt(1).setIcon(R.drawable.ic_tab_favorite);
tabs.getTabAt(2).setIcon(R.drawable.ic_tab_forum);
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
app_bar_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" …
Run Code Online (Sandbox Code Playgroud) android android-fragments android-view android-viewpager android-tablayout
如何根据UITableViewCells中的内容量来扩展它们?在我的单元格中,我使用3个代表论坛的标签.标签名为"别名","日期"和"评论".第三个标签注释,可以是任意数量的大小.因此,我的单元格需要动态变化,具体取决于"注释"标签的大小.以下是我的相关代码:
- (UITableViewCell *)tableView:(UITableView *)pTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ForumthreadCell";
UITableViewCell *cell = [pTableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
Feedback *item = [self.items objectAtIndex:indexPath.row];
UILabel *aliasLabel = (UILabel *)[cell viewWithTag:1];
UILabel *commentLabel = (UILabel *)[cell viewWithTag:2];
UILabel *dateLabel = (UILabel *)[cell viewWithTag:3];
[aliasLabel setText:item.alias];
[commentLabel setText:item.comment];
[dateLabel setText:[self.dateFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:(double)item.time]]];
commentLabel.numberOfLines = 0;
[commentLabel sizeToFit];
CGSize textHeight = [commentLabel.text sizeWithFont:commentLabel.font constrainedToSize:CGSizeMake(maxWidth, lineHeight * commentLabel.numberOfLines)lineBreakMode:UILineBreakModeWordWrap];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
如您所见,我使用textHeight设置commentsLabel的高度.但是从现在开始我该怎么办?如果我知道标签的高度,我如何根据commentLabel的高度设置Cell的高度?请根据我的代码提供代码示例.我想我应该使用以下方法,但我不知道该怎么做:
- …
Run Code Online (Sandbox Code Playgroud) ios ×6
android ×3
android-view ×1
image ×1
ios7 ×1
iphone ×1
objective-c ×1
slide ×1
slideshow ×1
transparent ×1
uibutton ×1
uisearchbar ×1
uislider ×1
uitabbar ×1
uitabbaritem ×1
uitableview ×1
uitextfield ×1
webview ×1