Hello All i am creating Tab bar programmatically, in my functionality there need to be selected tab filled with custom color, i have achieved this so far using below code and the following output see screenshot.
tabBarController.tabBar.selectionIndicatorImage = UIImage.imageWithColor(color: colors.AppSkyBlue, size: tabBarItemSize).resizableImage(withCapInsets: UIEdgeInsets(top: 1, left: 1, bottom: 1, right: 1), resizingMode: .stretch)
Clearly see the white space be around selected tab, ho do i remove this from all side. Any help would be appreciated well.
You Could simple add a subview on top of UITabBar and give the bg color same as the color of tab bar - so it blends with it
var lineView = UIView(frame: CGRect(x: 0, y: 0, width:tabBarController.tabBar.frame.size.width, height: 1))
lineView.backgroundColor = UIColor.grey
tabBarController.tabBar.addSubview(lineView)
This is one of the options.
Related
I want to put scrollViewIndicator just a bit more outside(right) of scrollView. But It doesn't go even if I set self.mainMenuCollectionView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 10, 0, 0);. It might because of inset works as padding and not going out of bounds of scrollView. It stays in the border.
It works for putting indise(left) of the view.
It would be really helpful if you know how can I achieve that.
N: normal
S: It is possible
W: How I want
You need to setup opposite side with minus sign like:
self.mainMenuCollectionView.scrollIndicatorInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: -10)
Don't forget disable clipsToBounds for getting visible subviews outside:
self.mainMenuCollectionView.clipsToBounds = false
I am adding a calendar to my app and thought it would be cool to mimic the format of standard iOS Calendar app as per weekday labels:
In the Calendar app, these labels (S,M,T,W,T,F,S) seem to be integrated into the navigation bar, so I was wondering if there is a way to implement this or if this is something Apple left to themselves (as there seems to be no standard way to add anything but bar button items). Mind you, these labels should be dynamic - e.g. rearrange in case of day 2 as firstWeekDay for certain Locale.
Apple proposes not to resize navigationBar itself, but remove shadow from bar and add custom view under your navigationBar.
Please refer the apple recommended approach for extended navigation bars here - https://developer.apple.com/library/content/samplecode/NavBar/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007418-Intro-DontLinkElementID_2
And your particular scenario - https://developer.apple.com/library/content/samplecode/NavBar/Listings/NavBar_ExtendedNavBar_ExtendedNavBarViewController_swift.html#//apple_ref/doc/uid/DTS40007418-NavBar_ExtendedNavBar_ExtendedNavBarViewController_swift-DontLinkElementID_13
You just need to set a view to your title view of navigationItem for example:
sampleLabel.textAlignment = .center
sampleLabel.textColor = UIColor.white
sampleLabel.font = UIFont.systemFont(ofSize: 12, weight: .medium)
sampleLabel.frame = CGRect(x: 0, y: 0, width: 40, height: 30)
sampleLabel.text = "T"
let titleView = UIView
titleView.frame = CGRect(x: 0, y: 0, width: 200, height: 50)
titleView.addSubview(sampleLabel)
navigationItem.titleView = titleView
You can add labels to your navigationBar like sampleLabel wherever you want.
I want to place information text in main scene of the application. When ı place a text view, its content starts at the middle. There is a between the text and top boundary of the TextView.
How can I make the text start at the first line of the TextView ?
You can set the contentOffset property of textView to zero like
textView.setContentOffset(CGPoint.zero, animated: false)
Swift 3
textView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
I Tried to give space like this self.tableView.contentInset = UIEdgeInsets(top: 20, left: 0, bottom: 20, right: 0)
but its not taking can any one suggests how to do that i need space in top of Types of homes . this form design in table view enter image description here
I've been trying to animate a change in UIEdgeInsets. I've already tried using UIView.animateWithDuration and the insets just jump to the final values. Does anyone know if this a property that can't be animated? Or better yet, is anyone aware of a way to animate insets?
As an example:
// Starting inset values
self.searchField.placeHolderInset = UIEdgeInsets(top: 0, left: 110, bottom: 0, right: 10)
// Animation block
UIView.animateWithDuration(0.1, animations: {
self.searchField.placeHolderInset = UIEdgeInsets(top: 0, left: 18, bottom: 0, right: 10)
})
Instead of moving 92 pixels to the left over 0.1 seconds, the text jumps to the final value. searchField is a UITextField and .placeHolderInset is the UIEdgeInset being used to determine the insets for the UITextField's placeholder text.
EDIT: Another way to achieve the desired effect is by changing the UITextField's .textAlignment from .Center to .Left but that won't animate either.
You need to call layoutIfNeeded() on the view, inside of the animation block.