ViewPager animation with slide imageview and textview fadein and fadeout - animation

In Android, I have a viewPager, with views having ImageView & some other TextView items. I want to animate with slide the ImageView and fadein-fadeout of other textviews. How can I achieve this?
Cheers
Annada

Related

NSView layer shadow draws on subviews, not view itself

I'm trying to set a shadow on the layer of an NSView, but the layer is being drawn on the subviews of my view, not the view itself. What can be causing this?
The view in question and all its subviews are layer-backed. All but one of the subviews are buttons (NSButton) with images - the other one is a custom view that renders via drawRect:.
self.layer.shadowColor = [[NSColor blackColor] colorWithAlphaComponent:0.9].CGColor;
self.layer.shadowRadius = 2;
self.layer.shadowOffset = NSMakeSize(0, -1);
self.layer.shadowOpacity = 0.9;
I've also tried setting the shadow via an NSShadow, with the same outcome.
Turns out that if you set a shadow on an NSView's layer, it only draws on that view if the view has a drawRect: implementation that draws something non-transparent. Otherwise it draws on all the view's subviews.
Weird.

UiScrollview with nested image looks weird

I have a UIScrollView inside a UIViewController (subclassed by ImageViewController). The ViewController itself is part of a NavigationController's stack. Now, apart from having a navigation bar, I want the ScrollView to take all of the available room on the screen. The UIImageView inside the scrollview should then fill the available room of the scroll view. You can see the current state at the bottom of this posting.
class ImageViewController: UIViewController, UIScrollViewDelegate {
#IBOutlet weak var scrollView: UIScrollView!
var imageView: UIImageView?
var image: UIImage?
override func viewDidLoad() {
super.viewDidLoad()
scrollView.delegate = self
if let image = image {
imageView = UIImageView(image: image)
if let imageView = imageView {
imageView.frame = CGRect(origin: CGPoint(x: 0, y: 0), size: image.size)
scrollView.addSubview(imageView)
scrollView.contentSize = image.size
let scaleHeight = scrollView.frame.size.height / scrollView.contentSize.height
let scaleWidth = scrollView.frame.size.width / scrollView.contentSize.width
let minimumScale:CGFloat = min(scaleHeight, scaleWidth)
let maximumScale:CGFloat = max(scaleHeight, scaleWidth)
scrollView.minimumZoomScale = minimumScale
scrollView.maximumZoomScale = maximumScale
scrollView.zoomScale = maximumScale
}
}
}
func viewForZoomingInScrollView(scrollView: UIScrollView) -> UIView? {
return imageView
}
}
The code leaves me with unnecessary borders (left, right, top). How do I get rid of them?
EDIT: With #Bxtr's suggestion and another stackoverflow thread I was able to remove the borders left and right to the scroll view. After some more digging I found out that by deactivating Adjust Scroll View Insets, the image inside the scroll view can be correctly vertically positioned. Still, I do not get the reason for the vertical misplacement in the first place...
Have you checked the margin/padding values, because it kinda looks so (same size on left and right border). If it is not the case, could you please also post your xml file of the activity so we can have every part of the puzzle to help you ?
scrollView.contentSize = image.size;
you have to tweek this line. You are explicitly setting scroll view content size to the image size. You have to set content size to fit the Width of Screen.
You can use a UIView in UIScrollView, and that UIView contains UIImage.
You need to set constraints properly.
After some more digging I found out that by deactivating Adjust Scroll
View Insets, the image inside the scroll view can be correctly
vertically positioned. Still, I do not get the reason for the vertical
misplacement in the first place...
The reason is that the view controller's automaticallyAdjustsScrollViewInsets property is by default YES, the following is from apple documentation:
automaticallyAdjustsScrollViewInsets
A Boolean value that indicates
whether the view controller should automatically adjust its scroll
view insets.
Default value is YES, which allows the view controller to adjust its
scroll view insets in response to the screen areas consumed by the
status bar, navigation bar, and toolbar or tab bar. Set to NO if you
want to manage scroll view inset adjustments yourself, such as when
there is more than one scroll view in the view hierarchy.
Besides setting automaticallyAdjustsScrollViewInsets = No, you can pin the scrollView to the topLayoutGuide (instead of to the top of the viewController's view) when using autoLayout.

Animation over the view with cocoa drawing

everybody! I perform cocoa drawing in view and perform some animation (moving text label) over this view. During the animation content in my view breaks:
before animation:
after animation:
How to improve this?
Thanks!
I replace dirtyRect with self.bounds:
- (void)drawRect:(NSRect)dirtyRect {
NSRect mainFrame = dirtyRect; //// <--- replace dirtyRect with self.bounds
//....drawing code
}

Change NSWindow background color with FadeIn Animation

I'm trying to build a Mac App (for the second time) and want to change the background color of my NSWindow with a fadein animation.
Right now, I've set the background image in this way:
NSImage *windowBG = [NSImage imageNamed:#"greenBG.png"];
[[self.window contentView] setWantsLayer:YES];
[[self.window contentView] layer].contents = windowBG;
On a particular event, I want to change the "greenBG.png" to "yellowBG.png" with a fadein animation.
Doing this in iOS is simpler, but how can this be done in Cocoa?

cocoa: resize split view subview size

I want to hide a subview after I click a button, for example.
after I click hide button, the application should hide the NSTabView,(Not NSTableView!!!). but the problem is the NSTableView at top didn't resize, as follow:
How to make NSTableView auto resize to fill the blank after I hide the NSTabView?
My code about hiding the bottom subView:
NSRect frame = [self.customView frame];
frame.size = NSMakeSize(0, 0);
[[self.customView animator] setFrame:frame];
In your code for the hide button, just include code that increases the frame size of your scroll view (that contains the table view).

Resources